Admob work android , not work ios

Admob work android , not work ios

 var admobid: AdMobType;
      if (/(android)/i.test(navigator.userAgent)) {
        admobid = { // for Android
          banner: 'ca-app-pub-4114335772429857/5775189921',
          interstitial: 'cca-app-pub-4114335772429857~2880599129'
        };
      } else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
        admobid = { // for iOS
          banner: 'ca-app-pub-4114335772429857/8408768727',
          interstitial: 'ca-app-pub-4114335772429857~6932035528'
        };
      } else {
        admobid = { // for Windows Phone
          banner: 'ca-app-pub-234234234234324/234234234234',
          interstitial: 'ca-app-pub-234234234234324/234234234234'
        };
      }

Now we have a list of Admob IDs and the code that defines it for 3 platforms. What should we do with it?

What do you do with it? Is there also some code to show Admob banners? Are you using a library to import Admob code?

 this.admob.createBanner({
        adId: admobid.banner,
        isTesting: false,//comment this out before publishing the app
        autoShow: true
      });

Where does this come from?`
What library is behind it?
How does it get imported to be used?

import { AdMob } from ‘@ionic-native/admob’;
private admob:AdMob
it works android . not work ios

Did you remote debug the problem on the device already? Follow these instructions here to debug the problem in Safari dev tools: https://ionic.zone/debug/remote-debug-your-app#ios Look at the console and network tabs for errors.

No problems appear. App is smoothly work but admob not show.android app admob is showing

Does it work if isTesting: true?

No false. But true does not work

Why are we not using Platform.is() instead of futzing around with parsing user agents?

Good question.

Better question:
Why are you not using the code from the documentation? https://ionicframework.com/docs/native/admob/
There seems to be another showBanner method to be called after createBanner if I read the docs right.

Hi there, I was facing the same issue on iOS… you have to make sure you wait for platform ready to be able to have it run properly on iOS, it seems that android doesn’t really care about that, but your code should look like this… in your home.ts file (or wherever you are wanting to show the ad)

constructor(public navCtrl: NavController, public admobFree: AdMobFree, platform: Platform) {
{
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
const bannerConfig: AdMobFreeBannerConfig = {
isTesting: false, // Remove in production
autoShow: true,
id: ‘YOUR OWN ID’
};

  this.admobFree.banner.config(bannerConfig);

  this.admobFree.banner.prepare().then(() => {
      // success
  }).catch(e => console.log(e));
  });
}
1 Like