I’m using this: https://ionicframework.com/docs/native/admob/
Well, the code work on both interstitial and banner for Android platform , but on iOS (simulator and phone), there is nothing, no test banner etc.
All admob unit id are ok!
my info:
global packages:
@ionic/cli-utils : 1.1.2
Cordova CLI : 7.0.0
Ionic CLI : 3.1.2
local packages:
@ionic/app-scripts : 1.3.7
@ionic/cli-plugin-cordova : 1.1.2
@ionic/cli-plugin-ionic-angular : 1.1.2
Ionic Framework : ionic-angular 3.2.1
System:
Node : v6.10.3
OS : Windows 10
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
The Code:
home.ts
import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import { AlertController } from ‘ionic-angular’;
import { AdMob } from ‘@ionic-native/admob’;
import { Platform } from ‘ionic-angular’;
@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {
admobid: any;
constructor(public navCtrl: NavController,public alertCtrl: AlertController, private admob: AdMob, private platform: Platform) {
if(this.platform.is('android')) { // for Android
this.admobid = {
banner : 'ca-app-pub-1xxx',
interstitial: 'ca-app-pub-2xxx'
}
} else if (this.platform.is('ios')) {// for iOS
this.admobid = {
banner : 'ca-app-pub-3xxx',
interstitial: 'ca-app-pub-4xxx'
}
}
this.admob.createBanner({
adId: this.admobid.banner,
isTesting: true,//comment this out before publishing the app
autoShow: false
})
this.admob.prepareInterstitial({
adId: this.admobid.interstitial,
isTesting: true, //comment this out before publishing the app
autoShow: false
})
//this.admob.prepareInterstitial({adId: adId})
//.then(() => { this.admob.showInterstitial(); });
}
show(){
if (this.admob)
{
this.admob.showInterstitial();
// this.showAlert();
}
}
show2(){
if (this.admob)
{
this.admob.showBanner(this.admob.AD_POSITION.TOP_CENTER);
}
}
showAlert() {
let alert = this.alertCtrl.create({
title: 'OK',
subTitle: this.admobid.interstitial,
buttons: ['OK']
});
alert.present();
}
}
home.html
Ionic Blank The world is your oyster.
If you get lost, the docs will be your guide.
Show Interstitial
2
And of course imported the admob on modules and providers
Can someone help me?
It is a ionic native and i’m testing since 10 hours without any results
The console log on xcode have this at the end
AdMob, onAdFailLoad, {‘adNetwork’:‘AdMob’,‘adType’:‘banner’,‘adEvent’:‘onAdFailLoad’,‘error’:1,‘reason’:‘Request Error: No ad to show.’}