首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >间隙广告(插件:无广告广告)

间隙广告(插件:无广告广告)
EN

Stack Overflow用户
提问于 2020-06-03 04:58:30
回答 2查看 381关注 0票数 0

我的兴趣是比较基本的。我所想要的就是在我的混合应用程序的一些页面上显示一个中间的横幅。我真的很感谢你的任何意见和指导,因为我是一个新手开发,只是一个业余爱好者。

我使用Adobe PhoneGap build web界面,我的"config.xml“成功地构建了我的apk,它很有魅力。

代码语言:javascript
复制
 <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> 

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

代码语言:javascript
复制
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>

在我的"js/index.js“文件中,当phonegap在构建期间注入时,没有cordova.js,如下所示:

代码语言:javascript
复制
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。横幅也不显示)

你能帮我解决这个问题吗?非常感谢你们所有人!

EN

回答 2

Stack Overflow用户

发布于 2020-06-03 05:09:41

由于您正尝试在测试模式下显示广告,因此请删除

代码语言:javascript
复制
id: admobid.interstitial

代码语言:javascript
复制
id: admobid.banner
票数 0
EN

Stack Overflow用户

发布于 2020-06-08 19:01:08

在准备横幅interstital时,您需要像这样显示它们:

代码语言:javascript
复制
admob.banner.show(); 
admob.interstitial.show();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62161295

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档