Search code examples
cordovaionic-frameworkadmobcordova-plugins

Admob cordova plugin in ionic app


I am implementing Admob using this cordova plugin: https://github.com/floatinghotpot/cordova-admob-pro

I have added the plugin and have this in my .config of an ionic application:

.config(function($ionicConfigProvider, $sceDelegateProvider){
  document.addEventListener("deviceready", function () {
    if(AdMob) 
      AdMob.createBanner({
        adId:'admob-banner-id-entered-here', 
        position:AdMob.AD_POSITION.BOTTOM_CENTER, 
        autoShow:true
      });
  });
}

Build and test in testflight and no banner ad showing. I have tried Admob, window.plugin.AdMob, window.Admob, and also injecting $cordovaAdMob and using $cordovaAdMob but no Banner appears.

How do I get this plugin to work? Thanks


Solution

  • Hey i implemented something like this in ionic1 with the same plugin. In a controller of a view put this.

    if (AdMob) var adbMob = AdMob.createBanner({
                    adId: ca-app-pub-6869992474017983/9375997553, // Test ID
                    isTesting: true, //For testing advices...
                    autoShow: true
                });
    

    This works :D

    Greetings