中间广告 (插件:admob-free)

问题描述 投票:0回答:1

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

我使用Adobe PhoneGap构建网页界面,我的 "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在构建时注入了,我的 "jsindex.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
1个回答
0
投票
因为你是试图在测试模式下显示你的广告删除。
id: admobid.interstitial
id: admobid.banner

0
投票

当你准备好 旗帜眶间 你要让他们看到这样的。

admob.banner.show(); 
admob.interstitial.show();
© www.soinside.com 2019 - 2024. All rights reserved.