Javascript AdMob Cordova未在Cordova应用程序中显示广告横幅
我是Cordova的新手,我想在我的Cordova应用程序中实现广告,我已经做了它的演示,但当我运行我的应用程序时,我看不到横幅。 我一直关注这个链接: 我做了与此链接相同的操作。我正在显示我的代码:Javascript AdMob Cordova未在Cordova应用程序中显示广告横幅,javascript,android,cordova,admob,Javascript,Android,Cordova,Admob,我是Cordova的新手,我想在我的Cordova应用程序中实现广告,我已经做了它的演示,但当我运行我的应用程序时,我看不到横幅。 我一直关注这个链接: 我做了与此链接相同的操作。我正在显示我的代码: function initAd(){ if ( window.plugins && window.plugins.AdMob ) { var ad_units = { ios : { banner: '
function initAd(){
if ( window.plugins && window.plugins.AdMob ) {
var ad_units = {
ios : {
banner: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx',
interstitial: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx'
},
android : {
banner: 'ca-app-pub-901042ds533264/4645275146',
interstitial: 'ca-app-pub-9010443dsd64/4610326568'
}
};
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, LARGE_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();
} else {
alert('admob plugin not ready');
}
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(){ });
}
function showBannerFunc(){
window.plugins.AdMob.createBannerView();}
function showInterstitialFunc(){
window.plugins.AdMob.createInterstitialView(); //get the interstitials ready to be shown and show when it's loaded.
window.plugins.AdMob.requestInterstitialAd();}
这是你的全部密码吗?因为我看不出你在哪里调用这些函数 如果您查看了新创建的项目,那么在
www/js/index.js
中的文件中,您应该在receivedEvent
函数中添加对函数的调用
在这里查看一下,但是如果您直接复制粘贴它,请确保添加app.initialize()
作为最新一行(如www/js/index.js
文件中)
问候,,
贝诺特