Search code examples
ionic-frameworkadmobionic2cordova-admob

AdMob on Ionic 2 not showing live ads


I have a problem with showing live ads in my hybrid application built in Ionic 2 framework. Whatever I do I'm getting only test ads. I've tried to solve it using several approaches. With imported AdMob native, declared as variable and even customized banner id's in admob-pro plugin with no success. Application is published in play store for almost two weeks now and updated 3 or 4 times and still showing only test ads.

Here is what I have tried already:

with declared but not imported AdMob:

declare var AdMob: any;

initializeApp() {
    this.platform.ready().then(() => {
      interface AdMobType  {
        banner: string
      }

      var admobid: AdMobType;

      admobid = { 
         banner: 'ca-app-pub-3382431837711226/3560481511'
      };

      if (AdMob) AdMob.createBanner({
        adId : admobid.banner,
        position: AdMob.AD_POSITION.BOTTOM_CENTER,
        autoShow: true
      });               
      StatusBar.styleDefault();          
    });
  }

with imported AdMob:

import {AdMob} from 'ionic-native';

initializeApp() {
    this.platform.ready().then(() => {

      var admobid = {};

      if (/(android)/i.test(navigator.userAgent)) {
        admobid = { 
          banner: 'ca-app-pub-3382431837711226/3560481511',
        };
      }

      if (AdMob) AdMob.createBanner({
        adId: admobid.banner,
        position: AdMob.AD_POSITION.BOTTOM_CENTER,
        autoShow: true
      });

      StatusBar.styleDefault();      
    });
  }

I don't know what else could be a problem. Thinking on Ionic 2 version that my app was built with.

Here is my system info:

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.37
Ionic App Lib Version: 2.0.0-beta.20
OS: Windows 7 SP1
Node Version: v4.5.0 

Any thoughts where is the problem?

Thank you in advance.


Solution

  • I've finally found what was causing this issue. AdMob Pro plugin v2.20.x used in this project was the problem. I upgraded it with 2.24.0 version and solved the problem. I hope it will help others with system configuration described earlier in this post.

    Good luck and happy coding.