问题描述
我正在使用 Ionic Framework,还有这个插件:
I'm using Ionic Framework, and this plugin:
https://github.com/floatinghotpot/cordova-plugin-admob
当我将应用部署到安卓手机时,我看到一个黑色矩形,但没有广告.
When I deployed the app to the android phone, I see a black rectangle, but no ad.
我真的不知道发生了什么......这是我的代码:
I don't really know what's happening.. This is my code:
$ionicPlatform.ready(function() {
$ionicPlatform.ready(function() {
//Admob
var am = window.plugins.AdMob;
am.createBannerView(
{
'publisherId': 'xxxxxxxxxx',
'adSize': am.AD_SIZE.SMART_BANNER,
'bannerAtTop': false
},
function() {
am.requestAd(
{
'isTesting': true
},
function() {
am.showAd(true);
},
function() {
/* Handle error */
}
);
},
function() {
/* Handle error */
}
);
});
当您安装之前的 admob 插件时,也会安装 Google play services 插件.如果有人可以帮助我,我将不胜感激.提前致谢
Google play services plugin is also installed when you installed the previous admob plugin. If anyone can help me, I would really appreciate it. Thanks in advance
推荐答案
我注意到您将 isTesting 设置为 true.如果您使用的是 Android 模拟器,则在此模式下可能无法呈现广告.
I noticed that you set isTesting to true. If you are using the Android simulator it may not render ads when you are in this mode.
还要确保您实际上使用了正确的发布者 ID.我知道它有时会让人感到困惑,因为 Admob 提供了一些可供选择的可能性.
Also make sure that you are in fact using the correct publisher id. I know it can sometimes be confusing since Admob gives a few possibilities to choose from.
我在我的博客上发表了一篇关于如何让 Admob 与 IonicFramework 一起工作的文章.可以在这里找到:
I made a post on how to get Admob working with IonicFramework on my blog. It can be found here:
https://www.thepolyglotdeveloper.com/2014/06/using-admob-ionicframework/
如果这仍然不起作用,请告诉我们,我们可以从那里进行故障排除.
If that still doesn't work, let us know and we can troubleshoot from there.
干杯,
这篇关于Admob - 横幅显示黑色背景且没有广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!