我试图将AdMob广告放到我的离子android应用中,并测试其功能,我制作了一个名为AdMobTest的离子应用。我使用的插件是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”变量所做的工作。所有变量都到达我希望它们去的地方。因此gotHereMsg1具有有关android ID的消息,并且ID也正确。gotHereMsg2返回“ window.AdMob为true”,这意味着正在执行createBanner和prepareInterstitial函数。最后,当我单击按钮时,getHereMsg3返回“显示插页式功能已执行”。即使所有功能都在执行中,并且显然可以识别window.AdMob,也不会显示任何横幅。希望这提供了足够的信息来解决此问题。可能值得注意的是,我正在使用ionicv1,并且代码已写入ionic的app.js文件中的$ ionicPlatform.ready函数下。
添加回答
举报
0/150
提交
取消