admob-google / admob-cordova

Google AdMob plugin for Cordova, Phonegap and Intel XDK ,support ios and android,support admob v1 and admob v2 ,Monetize your html5 app with one javascript line.api is easy to use.
65 stars 50 forks source link

Interstitial code pls! #16

Closed gregstein closed 8 years ago

gregstein commented 8 years ago

Hi, It's been two days now and I couldn't figure a way to show interstitial ad. Could someone help me with please ?

Thank you in advance,

admob-google commented 8 years ago

https://github.com/admob-google/admob-cordova/blob/master/Example/interstitial.html

gregstein commented 8 years ago

Thank you so much mate! I have removed some of the alerts, is it gonna work like this ?

<script type="text/javascript">
    function showInterstitial(){
        admob.isInterstitialReady(function(isReady){
            if(isReady){
                admob.showInterstitial();
            }else{

            }
        });
    }

       alert("load fail: "+message.type+"  "+msg);
    }
    function onDeviceReady() {
        admob.initAdmob("banner ID","interstitial ID");
        document.addEventListener(admob.Event.onInterstitialReceive, onInterstitialReceive, false);
        document.addEventListener(admob.Event.onInterstitialFailedReceive,onReceiveFail, false);
    }
    document.addEventListener('deviceready',onDeviceReady, false);
</script>
admob-google commented 8 years ago
function onInterstitialReceive (message) {
admob.showInterstitial();//show when load success
}
function onReceiveFail (message) {
    var msg=admob.Error[message.data];
    if(msg==undefined){
       msg=message.data;
    }
admob.cacheInterstitial();//load again when load fail
   alert("load fail: "+message.type+"  "+msg);
}
function onDeviceReady() {
    admob.initAdmob("banner ID","interstitial ID");//init admob 
    document.addEventListener(admob.Event.onInterstitialReceive, onInterstitialReceive, false);
    document.addEventListener(admob.Event.onInterstitialFailedReceive,onReceiveFail, false);
admob.cacheInterstitial();// start load 
}
document.addEventListener('deviceready',onDeviceReady, false);
gregstein commented 8 years ago

Thank you so much <3