【问题标题】:interstitial ad (plugin: admob-free)插页式广告(插件:admob-free)
【发布时间】:2020-09-21 11:16:52
【问题描述】:

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

我使用 Adob​​e 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


    【解决方案1】:
    由于您正尝试在测试模式下展示您的广告,请移除
    id: admobid.interstitial
    
    id: admobid.banner
    

    【讨论】:

    • 我通过 webportal 在调试模式下构建 apk 并在 Android Studio AVD/Simulator 中进行测试。删除了行但没有用。无论如何,非常感谢。
    【解决方案2】:

    当您准备 bannerinterstital 时,您需要像这样展示它们:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多