Я новичок в Cordova, хочу внедрить Ads в своем приложении Cordova, я сделал его демо, но не вижу баннера при запуске приложения.Я перешел по этой ссылке: https://www.npmjs.com/package/cordova-plugin-admob-simple Я сделал то же, что и по этой ссылке.я показываю свой код:
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();}