插页式广告(插件:无广告)



我的兴趣相对非常基础。我想要的插页式横幅会显示在我的混合应用程序的某些页面中。我非常感谢您的任何评论和指导,因为我是一个新手开发人员,只是一个业余爱好者。

我使用Adobe PhoneGap构建Web界面,我的"config.xml"成功构建了我的apk,该apk工作魅力。

<preference name="android-build-tool" value="gradle" />
<preference name="phonegap-version" value="cli-7.1.0" />
<plugin name="cordova-plugin-admob-free">
<variable name="ADMOB_APP_ID" value="ca-app-pub-1122334455667788~12345" /> 
</plugin> 

我的应用程序是HTML5也使用Jquery。 索引.html页面调用以下 JS 文件。

<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>

没有cordova.js因为phonegap在构建过程中注入了我的"js/index.js"文件,如下所示,

var admobid = {}
if (/(android)/i.test(navigator.userAgent)) {  // for android & amazon-fireos
admobid = {
banner: 'ca-app-pub-1122334455667788/12345',
interstitial: 'ca-app-pub-1122334455667788/12345',
}
} else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {  // for ios
admobid = {
banner: 'ca-app-pub-1122334455667788/12345',
interstitial: 'ca-app-pub-1122334455667788/12345',
}
}
document.addEventListener('deviceready', function() {
admob.banner.config({
id: admobid.banner,
isTesting: true,
autoShow: true,
})
admob.banner.prepare()
admob.interstitial.config({
id: admobid.interstitial,
isTesting: true,
autoShow: true,
})
admob.interstitial.prepare()
document.getElementById('showAd').disabled = true
document.getElementById('showAd').onclick = function() {
admob.interstitial.show()
}
}, false)
document.addEventListener('admob.banner.events.LOAD_FAIL', function(event) {
console.log(event)
})
document.addEventListener('admob.interstitial.events.LOAD_FAIL', function(event) {
console.log(event)
})
document.addEventListener('admob.interstitial.events.LOAD', function(event) {
console.log(event)
document.getElementById('showAd').disabled = false
})
document.addEventListener('admob.interstitial.events.CLOSE', function(event) {
console.log(event)
admob.interstitial.prepare()
})

我成功构建了应用,但没有显示插页式广告。(PS. 横幅也没有出现(

你能帮我弄清楚吗?非常感谢大家!

因为您尝试在测试模式下展示广告,请移除
id: admobid.interstitial
id: admobid.banner

当你准备横幅插页式广告时,你需要像这样显示它们:

admob.banner.show(); 
admob.interstitial.show();

最新更新