admob-google / admob-phonegap

admob phonegap plugin(admob cordova plugin) is a phonegap plugin for admob native ad service,enable html5 developer to add admob ad in their phonegap application and cordova application for platform ios and android
22 stars 30 forks source link

Show interstitial on Game Over, not by pressing buttons #3

Open lumierephoto opened 8 years ago

lumierephoto commented 8 years ago

I've tested the index.html in the Example folder and got the app to shows ads.

However, I'm looking for a more real world solution where I can load an interstitial ad on Game Over in a HTML 5 game. I don't want to have to manually cache the ad and then trigger the interstitial with a button.

What is the best way to do this?

I've tried triggering the load interstitial and show interstitial in their own functions and then loading them in the body onLoad like so:

`function onLoad(){ admob.cacheInterstitial(); document.addEventListener('deviceready',onDeviceReady, false); }

function onDeviceReady() { showInterstitial(); }

body onload="onLoad();"`

However this didn't work.

I haven't done this successfully with Javascript as this isn't my best language. Any help appreciated!

admob-google commented 8 years ago

function onDeviceReady() { admob.cacheInterstitial(); } function onGameOver(){//call this fun to show when game over, at the same time to show your game over panel admob.isInterstitialReady(function(isReady){ if(isReady){ admob.showInterstitial(); } }); }

with this version plugin https://github.com/admob-google/admob-cordova

lumierephoto commented 8 years ago

Thanks for the quick response.

I'll try it out and get back to you.

lumierephoto commented 8 years ago

Wait.

Are you saying to use this plugin instead?

https://github.com/admob-google/admob-cordova

Not the Phonegap plugin?

https://github.com/admob-google/admob-phonegap

If so, why? I believe my project is Phonegap and not Cordova, that's why I ask.

admob-google commented 8 years ago

the plugin is the same for cordova and phonegap. https://github.com/admob-google/admob-cordova is a upgraded version of https://github.com/admob-google/admob-phonegap. and just fix some bug and optimize api.