如何获得奖励视频才能在无cordova-plugin-admob的情况下正常工作?

时间:2019-04-03 18:23:14

标签: javascript html cordova cordova-plugins

通过在我的jquery移动应用的单页文档中放置onClick="admob.interstitial.show()"事件,我成功地显示了无cordova-plugin-admob-free的真实admob横幅广告和插页式广告,但是除非您onClick="admob.rewardvideo.show()"工作正常我将id="showAd"放在了<a>属性中,但这仅适用于我放置的所有<a>属性中的前<a id="showAd">

是否可以在html文档中添加代码以使Admob奖励视频可以在无Cordova-plugin-admob的情况下正常工作?

这有效:<a onClick="admob.interstitial.show(); ExitApp()" data-iconpos="notext" data-icon="delete" class="ui-btn-left">Close</a>

这不起作用:<a href="https://docs.google.com/uc?export=download&id=0B5FDr8fLVGjRTWRCOWEwNC04TVU" data-role="button" onClick="admob.rewardvideo.show()">Download PDF</a>

这些是我包含在html中的basic.js内部代码:


    var admobid = {}
    if (/(android)/i.test(navigator.userAgent)) {  // for android & amazon-fireos
      admobid = {
        banner: 'ca-app-pub-3940256099942544/6300978111',
        interstitial: 'ca-app-pub-3940256099942544/1033173712',
      }
    } else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {  // for ios
      admobid = {
        banner: 'ca-app-pub-3940256099942544/2934735716',
        interstitial: 'ca-app-pub-3940256099942544/4411468910',
      }
    }

    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: false,
      })
      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()
    })

这些是来自mediation.js的:


    document.addEventListener('deviceready', function() {
      admob.rewardvideo.config({
        id: 'ca-app-pub-5123658954256325/6485882531',
        isTesting: false,
        autoShow: false,
      })
      admob.rewardvideo.prepare()

      document.getElementById('showAd').disabled = true
      document.getElementById('showAd').onclick = function() {
        admob.rewardvideo.show()
      }
    }, false)

    document.addEventListener('admob.rewardvideo.events.LOAD_FAIL', function(event) {
      console.log(event)
    })

    document.addEventListener('admob.rewardvideo.events.LOAD', function(event) {
      console.log(event)
      document.getElementById('showAd').disabled = false
    })

    document.addEventListener('admob.rewardvideo.events.CLOSE', function(event) {
      console.log(event)

      admob.rewardvideo.prepare()
    })

0 个答案:

没有答案