尝试使用其他插件,因为这个插件似乎已经损坏了。我知道这个插件是有效的。
https://github.com/sunnycupertino/cordova-plugin-admob-simple
cordova plugin add cordova-plugin-admob-simple
集成步骤如下:
-添加以下JavaScript函数,放入您自己的广告代码,并根据需要调整变量。
-从onDeviceReady()中调用initAd(),并使用showBannerFunc()和showInterstitialFunc()显示广告。
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-xxxxxxxxxxx/xxxxxxxxxxx',
interstitial: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx'
}
};
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,
bannerAtTop: false,
overlap: true,
offsetTopBar: false,
isTesting: false,
autoShow: false
});
registerAdEvents();
window.plugins.AdMob.createInterstitialView();
window.plugins.AdMob.requestInterstitialAd();
} else {
}
}
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();
window.plugins.AdMob.requestInterstitialAd();
});
}
function showBannerFunc(){
window.plugins.AdMob.createBannerView();
}
function showInterstitialFunc(){
window.plugins.AdMob.showInterstitialAd();
}