我正在尝试使用Adonic 2和Angular 2的AdMob Free(cordova-plugin-admob-free),但我一直收到以下错误:
要构建项目,我会执行以下操作:
在app.module.ts
import { AdMobFree } from '@ionic-native/admob-free';
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AdMobFree
]
在home.ts
import { AdMobFree, AdMobFreeBannerConfig } from '@ionic-native/admob-free';
constructor(public navCtrl: NavController, private admobFree: AdMobFree)
在ngOnInit方法中:
const bannerConfig: AdMobFreeBannerConfig = {
// add your config here
// for the sake of this example we will just use the test config
isTesting: true,
autoShow: true
};
this.admobFree.banner.config(bannerConfig);
this.admobFree.banner.prepare()
.then(() => {
// banner Ad is ready
// if we set autoShow to false, then we will need to call the show method here
})
.catch(e => console.log(e));
有人可以帮助我吗?
非常感谢!
编辑:问题解决了!我没有更新SDK。对不起我的错:(
答案 0 :(得分:0)
答案 1 :(得分:0)
let adId;
if (this.platform.is('android')) {
adId = 'ca-app-pub-xxxxxxxxxxx';
var option: any = {
adId: 'ca-app-pub-xxxxxxxxxxx',
//size: 'SMART_BANNER',
//position: admob.AD_POSITION.BOTTOM_CENTER,
autoShow: true,
isTesting: true,
};
console.log("option", option);
this.admob.createBanner(option).then(() => {
this.admob.showBanner(8);
});
} else if (this.platform.is('ios')) {
adId = 'ca-app-pub-xxxxxxxxxxx';
var option: any = {
adId: 'ca-app-pub-xxxxxxxxxxx',
//size: 'SMART_BANNER',
//position: admob.AD_POSITION.BOTTOM_CENTER,
autoShow: true,
isTesting: true,
};
console.log("option", option);
this.admob.createBanner(option).then(() => {
this.admob.showBanner(8);
});
}
this.admobFree.banner.prepare()
.then(() => { this.admobFree.banner.show(); });