我試圖將AdMob廣告放到我的離子android應(yīng)用中,并測試其功能,我制作了一個名為AdMobTest的離子應(yīng)用。我使用的插件是cordova-admob-pro插件。這是我的AdMob代碼:var admobid = {};if (/(android)/i.test(navigator.userAgent)) { //Android admobid = { banner : 'ca-app-pub-2586564966169402/9782816366', interstitial : 'ca-app-pub-2586564966169402/8345912938', gotHereMsg1 : 'banner and interstitial have the android IDs' };} else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { //iOS admobid = { banner : 'Stand in iOS banner ID', interstitial: 'stand in iOS interstitial ID', gotHereMsg1 : 'banner and interstitial have the iOS IDs' };} else { //Neither admobid = { gotHereMsg1 : 'banner and interstitial have no IDs' }}if (window.AdMob) { var admob = window.AdMob; admob.createBanner ({ adId : admobid.banner, position : admob.AD_POSITION.BOTTOM_CENTER, isTesting : false, //False for live ; True for production autoShow : true }); admob.prepareInterstitial ({ adId : admobid.interstitial, autoShow : false }); gotHereMsg2 = "window.AdMob is true";} else { gotHereMsg2 = "window.AdMob is not true";}//Got an ID and the actual ID'sdocument.getElementById("getIdCheck").innerHTML = admobid.gotHereMsg1;document.getElementById("bannerId").innerHTML = admobid.banner;document.getElementById("interstitialId").innerHTML = admobid.interstitial;//window.AdMob is true and banner is created + interstitial is prepareddocument.getElementById("isWindowAdmob").innerHTML = gotHereMsg2;//Show interstitial function is executed or has not been executeddocument.getElementById("startInterstitial").onclick = function () {為了顯示我在測試中使用“ gotHereMsg”變量所做的工作。所有變量都到達(dá)我希望它們?nèi)サ牡胤?。因此gotHereMsg1具有有關(guān)android ID的消息,并且ID也正確。gotHereMsg2返回“ window.AdMob為true”,這意味著正在執(zhí)行createBanner和prepareInterstitial函數(shù)。最后,當(dāng)我單擊按鈕時,getHereMsg3返回“顯示插頁式功能已執(zhí)行”。即使所有功能都在執(zhí)行中,并且顯然可以識別window.AdMob,也不會顯示任何橫幅。希望這提供了足夠的信息來解決此問題。可能值得注意的是,我正在使用ionicv1,并且代碼已寫入ionic的app.js文件中的$ ionicPlatform.ready函數(shù)下。
Cordova admobpro廣告未在Android設(shè)備上展示
Qyouu
2021-04-05 12:15:44