Search code examples
javascriptcordovaadmobcordova-plugins

Cordova: AdModPro plugin hanging on createbanner()


I'm having some problems with the Cordoca AdModPro plugin, and maybe it has something to do with me being new to javascript and I'm just missing something obvious.

I got the ads working fine, the banner shows up in my app, and even the ad interstitial works great. My problem seems to be with ad initialization. When I am setting up the ad, the entire app seems to hang for 5 to 10 seconds while the admob banner is created. (I've connected my android phone to my PC and can watch what it is doing during that 10 second hang, and it is definitely in admob code). Here's the snippet:

          if (/(android)/i.test(navigator.userAgent)) { // for android & amazon-fireos
    Match3.admobid = {
         banner: 'ca-app-pub-/XXX', // or DFP format "/6253334/dfp_example_ad"
         interstitial: 'ca-app-pub-/XXX'
     };
 if (AdMob) AdMob.createBanner({
     adId: Match3.admobid.banner,
     position: AdMob.AD_POSITION.TOP_CENTER,
     isTesting: true,
     autoShow: true,
     overlap: true
 });         
 } else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { // for ios
     Match3.admobid = {
         banner: 'ca-app-pub-/XX', // or DFP format "/6253334/dfp_example_ad"
         interstitial: 'ca-app-pub-/XXX'
     };
 if (AdMob) AdMob.createBanner({
     adId: Match3.admobid.banner,
     position: AdMob.AD_POSITION.TOP_CENTER,
     isTesting: true,
     autoShow: true,
     overlap: true
 });         
 } else { // for windows phone
     Match3.admobid = {
         banner: 'ca-app-pub-/XXX', // or DFP format "/6253334/dfp_example_ad"
         interstitial: 'ca-app-pub-/XXX'
     };
 }

And the code IS actually working. I just can't figure out why the phone is hanging. Shouldn't this stuff be running in a background thread or something? I've tried moving this code around into different spots of the code (even in onDeviceReady() ) but no matter where I put it, it hangs for around 10 seconds when it runs.

Am I missing something? Is this something that you just have to work around and mask the loading as best you can? Or is it not really working right?


Solution

  • Ok, I figured out this is a known problem with the admobpro plugin for cordova:

    https://github.com/floatinghotpot/cordova-admob-pro/issues/504

    I was able to get around it by following the instructions above, and installing an older version of admobpro:

    cordova-plugin-admobpro v2.12.0 and cordova-plugin-extension v1.2.9

    Works great now!