Phonegap cordova-plugin-admob-simple 无法展示任何广告



我到了智慧的尽头。我无法让这个插件工作。我已经按照 PhoneGap Cordova Admob 插件不起作用的说明进行操作(当您向下滚动到引用此插件的答案时。我使用最新的 phonegap cli 与 phonegap 服务一起运行。我甚至创建了一个空页面(debug.html)以确保没有其他代码干扰。

到目前为止我做了什么:

  • 确保插件存在于主配置中.xml
  • 在网络浏览器中检查Admob.js文件实际上是从插件文件夹加载的。
  • 确保该插件在 platform/android/android.json 中被引用
  • 确保我在页面上链接了科尔多瓦.js
  • 确保插件位于平台/android/assets/www/plugins
  • 添加了平台安卓
  • 插件显示在电话间隙插件列表中
  • 安装插件和/或运行 phonegap 服务时没有错误
  • 尝试用是测试真假
  • 确保设备就绪实际上正在触发
  • 检查
  • 并重新检查了我的 AdMob 代码。

我总是收到"admob 插件未准备好"的警报。

我尝试将"window.plugins.AdMob"行更改为AdMob,插件。Admob,导航员。阿德莫布,窗口。阿德莫布。我仍然收到此错误。

当我注释掉该检查("if (window.plugins && window.plugins.AdMob ) {")并强制它运行代码时,什么也没发生。我在命令行上没有错误,在我可以找到要调试的任何地方都没有错误。

这是我的代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<meta name="msapplication-tap-highlight" content="no" />
<title>Debug Page</title>
<style>
.bodyStyle{
font-size: 32px;
}
</style>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script> 
</head>
<body >
<script>
function onDeviceReady() {
console.log("DEVICE READY");
//initialize the goodies
if ( window.plugins && window.plugins.AdMob ) {
var ad_units = {
ios : {
banner: 'ca-app-pub-1631005955280974/1599263468',       //PUT ADMOB ADCODE HERE
interstitial: 'ca-app-pub-1631005955280974/6029463060'  //PUT ADMOB ADCODE HERE
},
android : {
banner: 'ca-app-pub-1631005955280974/1599263468',       //PUT ADMOB ADCODE HERE
interstitial: 'ca-app-pub-1631005955280974/6029463060'  //PUT ADMOB ADCODE HERE
}
};
var admobid = ( /(android)/i.test(navigator.userAgent) ) ? ad_units.android : ad_units.ios;
window.plugins.AdMob.setOptions( {
publisherId: admobid.banner,
interstitialAdId: admobid.interstitial,
adSize: window.plugins.AdMob.AD_SIZE.SMART_BANNER,  //use SMART_BANNER, BANNER, IAB_MRECT, IAB_BANNER, IAB_LEADERBOARD
bannerAtTop: false, // set to true, to put banner at top
overlap: true, // banner will overlap webview 
offsetTopBar: false, // set to true to avoid ios7 status bar overlap
isTesting: true, // receiving test ad
autoShow: true // auto show interstitial ad when loaded
});
registerAdEvents();
window.plugins.AdMob.createInterstitialView();  //get the interstitials ready to be shown
window.plugins.AdMob.requestInterstitialAd();
} else {
alert( 'admob plugin not ready' );
}
//functions to allow you to know when ads are shown, etc.
function registerAdEvents() {
document.addEventListener('onReceiveAd', function(){});
document.addEventListener('onFailedToReceiveAd', function(data){});
document.addEventListener('onPresentAd', function(){});
document.addEventListener('onDismissAd', function(){ });
document.addEventListener('onLeaveToAd', function(){ });
document.addEventListener('onReceiveInterstitialAd', function(){ });
document.addEventListener('onPresentInterstitialAd', function(){ });
document.addEventListener('onDismissInterstitialAd', function(){
window.plugins.AdMob.createInterstitialView();          //REMOVE THESE 2 LINES IF USING AUTOSHOW
window.plugins.AdMob.requestInterstitialAd();           //get the next one ready only after the current one is closed
});
}
function showBannerFunc(){
AdMob.createBannerView();
}
//display the interstitial
function showInterstitialFunc(){
AdMob.showInterstitialAd();
}
document.addEventListener("deviceready", onDeviceReady, false);
</script>
<button type='button' onclick='showBannerFunc();'>SHOW BANNER</button>
<br/><br/>
<button type='button' onclick='showInterstitialFunc();'>SHOW INTER</button>
</body>
</html>

它在主配置中.xml作为

<plugin name="cordova-plugin-admob-simple" spec="~3.3.3" />

拜托,我已经在这里呆了 2 个多星期,我已经用谷歌搜索并搜索了我能搜索的一切。我必须阅读至少 100 页寻求帮助,但不知道还能尝试什么。我发现的一切,我都无济于事。甚至没有什么不同,它只是不显示任何类型的广告。横幅或其他。即使我点击按钮。请帮帮我。谢谢。

好的,我终于想通了。我正在使用Phonegap Serve。这不支持插件,或至少第三方插件。你必须使用Phonegap运行。

我目前处于您 2 周前的阶段。我已经为 Admob 测试了不同的插件,但没有显示广告。 不幸的是,即使我生成apk文件并在移动设备上运行它,也没有任何反应。 我使用了您的代码,但是按下"显示横幅"按钮时没有显示任何内容。

我使用了虚拟 ID (ca-app-pub-3940256099942544/6300978111) 以及我自己的 ID。

也许你可以看看我的问题并给出一个建议: 使用 AdMob 和科尔多瓦 - 广告不显示

谢谢

彼得

相关内容

最新更新