Hello there , that’s my first post in the forum So I have the following issue , I’ve started learning ionic framework 2 weeks ago , I’ve installed ionic with
npm install -g ionic
And now I’m trying to run video reward ad or banner ad via AdMob plugin , but it doesn’t work.
home.html
<p>
<button ion-button (click)="loadAd();">Show Ad</button>
</p>
home.ts
import { Component } from '@angular/core';
import { AdMob } from '@ionic-native/admob';
import { Platform } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(private admob: AdMob , private platform: Platform) {
}
loadAd() {
this.admob.createBanner({
adId: 'ca-app-pub-1603379825259521/2476422091',
adSize: 'SMART_BANNER',
isTesting: false
}).then(() => {
this.admob.showBanner(8);
});
}
Then Im running my project via Genymotion ( ionic cordova run android
) and nothing happens when I click the button. Any suggestions ? I really want to learn how to place ads and work with AdMob and Ionic. Is the issue related that I am running ionic 3 ? ( ionic -v
returns 3.4.0). Any help is appreciated , thanks
P.s I’ve also tried to run AdMob as it’s mentioned in the docs , but that didn’t work too.
ionViewDidLoad() {
this.admob.onAdDismiss()
.subscribe(() => { console.log('User dismissed ad'); });
}
onClick() {
let adId;
if(this.platform.is('android')) {
adId = 'YOUR_ADID_ANDROID';
} else if (this.platform.is('ios')) {
adId = 'YOUR_ADID_IOS';
}
this.admob.prepareInterstitial({adId: adId})
.then(() => { this.admob.showInterstitial(); });
}