Search code examples
cordovaadmobintel-xdkintel-xdk-contacts

How to integrate Admob in xdk


I have used the links below and I always receive this error admob plugin not ready on device.

[https://github.com/floatinghotpot/cordova-plugin-admob] [https://software.intel.com/en-us/html5/articles/adding-google-play-services-to-your-cordova-application]

What should I do? Please, help me.

Thank you in advance.


Solution

  • Are you waiting for deviceready to start the ads? (see this answer here: https://stackoverflow.com/a/26214464/4025963):

    document.addEventListener("deviceready", onDeviceReady, false);
    
    function onDeviceReady() {
      document.removeEventListener("deviceready", onDeviceReady, false);
      if (admob) {
         // YOUR ADMOB KEY HERE
        admob.createBannerView({publisherId: 'ca-app-pub-xxx/xxx'});
        admob.requestInterstitialAd({interstitialAdId: 'ca-app-pub-xxx/xxx', autoShowInterstitial: true});
      }
    }
    

    I'm using this plugin: https://github.com/appfeel/admob-google-cordova and it works for me and it also has an example of integration with intel XDK that I've tested in an iPhone.