Unable to get AdMob banner to show up on Ionic iOS app


#1

Hi, I’m running Ionic v1.3 and cordova 6.1.1. I followed these 2 popular and similar tutorials about adding AdMob to an Ionic app:


http://www.nikola-breznjak.com/blog/codeproject/adding-admob-to-ionic-framework-application-step-by-step/

At first I ran into an issue trying to install the plugin that couldn’t be found: cordova plugin add com.rjfun.cordova.plugin.admob

I read that if i’m running Cordova v5 or higher to use this plugin instead: https://github.com/floatinghotpot/cordova-admob-pro

My Question is how do I call the AdMob plugin? There are examples showing a separate “AdMob.js” file or calling the code from “App.js” inside the function:

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // INSERT ADMOB HERE?
  {
});

And does anyone have an example of what their AdMob code looks like just for a banner? Does it look like this?

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.AdMob) {

      var admob_key = device.platform == "Android" ? "ANDROID_PUBLISHER_KEY" : "IOS_PUBLISHER_KEY";
      var admob = window.cordova.plugins.AdMob;
      admob.createBannerView( 
          {
              'publisherId': admob_key,
              'adSize': admob.AD_SIZE.BANNER,
              'bannerAtTop': false
          }, 
          function() {
              admob.requestAd(
                  { 'isTesting': true }, 
                  function() {
                      admob.showAd(true);
                  }, 
                  function() { console.log('failed to request ad'); }
              );
          }, 
          function() { console.log('failed to create banner view'); }
      );
  }
  {
});

Am I forgetting something super easy? Is there a way to test to make sure I loaded the AdMobPro plugin?

Thanks in advance :slight_smile: