android - admob interstitial ad issue? -


i developing app using cordova phonegap android plateform.

i install user ads plugin in app, working fine in device moto g interstitial ad opening after leave app.

please let me know if of have face issue , fixed it.

any appreciated.

please see documentation here (i've udated right now): https://github.com/appfeel/admob-google-cordova/wiki/showinterstitialad

note: interstitials may shown if android app in background. reason recommended stop banners , interstitials , reload when onpause , onresume events detected.

for reason, should listen onpause , onresume events:

var isappforeground = true;  function onadloaded(e) {   if (isappforeground) {     if (e.adtype === admob.ad_type.interstitial) {       admob.showinterstitialad();     }   } }  function onpause() {   if (isappforeground) {     admob.destroybannerview();     isappforeground = false;   } }  function onresume() {   if (!isappforeground) {     settimeout(admob.requestinterstitialad, 1);     isappforeground = true;   } }  // optional, in case respond events function registeradevents() {   document.addeventlistener(admob.events.onadloaded, onadloaded);    document.addeventlistener("pause", onpause, false);   document.addeventlistener("resume", onresume, false); }  function initads() {   if (admob) {     var adpublisherids = {       ios : {         banner : "ca-app-pub-xxxxxxxxxxxxxxxx/bbbbbbbbbb",         interstitial : "ca-app-pub-xxxxxxxxxxxxxxxx/iiiiiiiiii"       },       android : {         banner : "ca-app-pub-xxxxxxxxxxxxxxxx/bbbbbbbbbb",         interstitial : "ca-app-pub-xxxxxxxxxxxxxxxx/iiiiiiiiii"       }     };      var admobid = (/(android)/i.test(navigator.useragent)) ? adpublisherids.android : adpublisherids.ios;      admob.setoptions({       publisherid:          admobid.banner,       interstitialadid:     admobid.interstitial,       autoshowinterstitial: false     });      registeradevents();    } else {     alert('admobads plugin not ready');   } }  function ondeviceready() {   document.removeeventlistener('deviceready', ondeviceready, false);   initads();    // request interstitial   admob.requestinterstitialad(); }  document.addeventlistener("deviceready", ondeviceready, false); 

Comments