【发布时间】:2020-09-21 11:16:52
【问题描述】:
我的兴趣比较基础。我想要一个插页式横幅显示在我的混合应用程序的某些页面中。我真的很感谢您的任何 cmets 和指导,因为我是一个新手开发人员,只是一个业余爱好者。
我使用 Adobe PhoneGap 构建 Web 界面,我的“config.xml”成功构建了我的 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。 index.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.横幅也没有出现)
你能帮我解决这个问题吗?非常感谢大家!
【问题讨论】:
标签: android cordova phonegap-plugins phonegap-build phonegap