Reputation: 788
I have an Ionic 4 app with the admob free plugin. This is my code to show my banner:
admob.service.ts
` BannerAd(admobid) {
let bannerConfig: AdMobFreeBannerConfig = {
isTesting: false,
autoShow: true,
id: admobid
};
this.admobFree.banner.config(bannerConfig);
this.admobFree.banner.prepare().then(() => {
// success
}).catch(e => alert(e));
} `
On a page I call this method like this:
this.admob.BannerAd(this.id);
The test ads works fine but when I wanna use the production ads the banner is shown as a black bar under the screen. I get 2 warnings in my google console.
common.js:290 Native: tried calling AdMobFree.config, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
common.js:290 Native: tried calling AdMobFree.prepare, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
I have already tried several solutions
Solution 1
Ionic 4 and Cordova is not available
Solution 2
Migrated to a new fresh project
How can I show the production ads in my Ionic 4 app?
Package.json
"dependencies": {
"@angular/common": "^7.2.2",
"@angular/core": "^7.2.2",
"@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2",
"@angular/platform-browser": "^7.2.2",
"@angular/platform-browser-dynamic": "^7.2.2",
"@angular/router": "^7.2.2",
"@ionic-native/admob-free": "^5.5.0",
"@ionic-native/core": "^5.5.0",
"@ionic-native/keyboard": "^5.5.0",
"@ionic-native/splash-screen": "^5.5.0",
"@ionic-native/status-bar": "^5.5.0",
"@ionic/angular": "^4.3.0",
"ajv": "^6.10.0",
"cordova-admob-sdk": "0.24.1",
"cordova-android": "8.0.0",
"cordova-plugin-admob-free": "0.26.0",
"cordova-plugin-ionic-keyboard": "2.1.3",
"cordova-promise-polyfill": "0.0.2",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"zone.js": "~0.8.29"
},
"devDependencies": {
"@angular-devkit/architect": "~0.12.3",
"@angular-devkit/build-angular": "~0.13.0",
"@angular-devkit/core": "~7.2.3",
"@angular-devkit/schematics": "~7.2.3",
"@angular/cli": "~7.3.1",
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "~7.2.2",
"@angular/language-service": "~7.2.2",
"@ionic/angular-toolkit": "~1.4.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^10.14.5",
"codelyzer": "~4.5.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-webview": "^3.1.2",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.0.0",
"tslint": "~5.12.0",
"typescript": "~3.1.6"
},
Upvotes: 0
Views: 1112
Reputation: 788
I have run the following command after 3 days:
ionic cordova build android --prod --release
I uploaded the APK file to the Google playstore for beta testing. When I installed the app on my phone to test. The ads appeared and everything works.
Upvotes: 0