Ionic app with google admob integration (cordova admob plugin free)
A demo ionic app with Google AdMob Advertisements integrated.
git clone https://github.com/MoAsmar/ionic-admob-demo.git
npm install
.
cordova plugin add cordova-plugin-admob-free --save
cordova plugin add cordova-admob-sdk
npm install @ionic-native/admob-free --save
ionic cordova platform add android
for android devices.ionic cordova platform add ios
for ios devices.-Ionic version 3.1.0.
-cordova (built with version 8.0.0).
connect your device and run the command:
ionic cordova run android
then the app will start you will see two buttons.
Show Banner will popup the banner:
Show Interstitial will show the full screen interstital:
set property isTesting to false and copy the banner Ad Unit ID from your admob and past it under id property as below example:
showBanner() {
let bannerConfig: AdMobFreeBannerConfig = {
isTesting: false, // Remove in production
autoShow: true,
id: 'ca-app-pub-xxxxxxxxx'
};
this.admob.banner.config(bannerConfig);
this.admob.banner.prepare().then(() => {
// success
}).catch(e => console.log(e));
}
note: for interstital ads do the same but copy the interstitial id from admob and add it under launchInterstitial() method.
for more options and settings, check the admob free plugin documentation