Hello, sometime ago I made a short test with admobfree plugin. It worked : Now I would do it again and the same code isn’t working.
So I set up a new project and it wasn’ t working too.
The code depends on https://www.joshmorony.com/integrating-google-admob-advertisements-in-ionic/
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { AdMobFree } from '@ionic-native/admob-free';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
AdMobFree,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
home.html
<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
The world is your oyster.
<p>
If you get lost, the <a href="http://ionicframework.com/docs/v2">docs</a> will be your guide.
<button ion-button (click)="showBanner()">Show Banner</button>
<button ion-button (click)="launchInterstitial()">Show Interstitial</button>
</p>
<p>result Banner: {{bannertext}} </p>
</ion-content>
home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { AdMobFree, AdMobFreeBannerConfig, AdMobFreeInterstitialConfig } from '@ionic-native/admob-free';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, public admob: AdMobFree) {
}
bannertext:string = '';
showBanner() {
let bannerConfig: AdMobFreeBannerConfig = {
isTesting: true, // Remove in production
autoShow: true
//id: Your Ad Unit ID goes here
};
this.admob.banner.config(bannerConfig);
this.admob.banner.prepare().then(() => {
this.bannertext = 'bannertext success';
}).catch(e => this.bannertext = 'bannertext e:' + e);
}
launchInterstitial() {
let interstitialConfig: AdMobFreeInterstitialConfig = {
isTesting: true, // Remove in production
autoShow: true
//id: Your Ad Unit ID goes here
};
this.admob.interstitial.config(interstitialConfig);
this.admob.interstitial.prepare().then(() => {
this.bannertext = 'interstitial success';
}).catch(e => this.bannertext = 'interstitial e:' + e);
}
}
No Errors in visual code ide, no errors on ionic cordva build android. this.bannertext shows sucess, but I have no banner ad or interstital ad.
So what is wrong with this code?
Best regards, anna-liebt
Additional
ionic info
cli packages: (C:\Users\admin\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.14.0
ionic (Ionic CLI) : 3.14.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 3.0.1
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.7.1
System:
Node : v6.11.0
npm : 3.10.10
OS : Windows 10
Misc:
backend : legacy