ratson / cordova-plugin-admob-free

New development has been moved to "admob-plus-cordova", https://github.com/admob-plus/admob-plus/tree/master/packages/cordova
https://github.com/admob-plus/admob-plus
MIT License
499 stars 214 forks source link

interstitial does not show up #434

Open nearhead opened 3 years ago

nearhead commented 3 years ago

Hello,

My interest is relatively very basic. All I wanted an interstitial banner shows up in some pages of my hybrid application. I indeed appreciate your any comments and guidance since I am a novice developer, a hobbyist only.

I use Adobe PhoneGap build web interface and my "config.xml" is successful to build my apk which works charm.

 <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> 

My app is an HTML5 uses Jquery as well. The index.html page calls following JS files.


<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>

There is no cordova.js as the phonegap injects during its build, My "js/index.js" file as follows,

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()
})

I build the app successfully but interstitial ads does not appear. (ps. banner does not appear either)

Could you please help me to figure this out? Huge thanks to all of you!