-
Notifications
You must be signed in to change notification settings - Fork 127
README
Made in Barcelona with Love and Code
Monetize your Cordova/Phonegap/XDK HTML5 hybrid apps and games with AdMob ads, using latest Google AdMob SDK.
- Now available with Ionic Native too
- Supports banner, interstitials and rewarded
- Optional Tappx backfill
With this Cordova/Phonegap/XDK plugin you can show AdMob ads as easy as:
admob.setOptions({
bannerAdId: "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB",
interstitialAdId: "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII"
});
admob.createBannerView();
admob.requestInterstitialAd();
admob.requestRewardedAd();
cordova-admob~4.1.15
and later are now updated to latest SDK's (ios managed by CocoaPods, android managed by gradle)
To update the plugin you should remove the plugin and add it again:
$ cordova plugin rm cordova-admob
$ npm cache clear
$ cordova plugin add cordova-admob
Sometimes removing the plugin causes an error (it's been reported to cordova https://issues.apache.org/jira/browse/CB-12083). If that happens, remove first cordova-libgoogleadmobads
manually:
$ rm plugins/cordova-libgoogleadmobads/ -rf
$ cordova plugin rm cordova-admob
$ npm cache clear
$ cordova plugin add cordova-admob
- Visual Scale Android, Visual Scale iOS, a free app to help doctors and physiotherapists in their daily work:
It was really easy to integrate, thanks.
- Military Quotes Android, an interesting free app for those interested in images and quotes from US Military.
It works like a charm. Test ads and real ads show up. Thanks so much for following up, awesome support.
- iOS: using latest AdMob SDK for iOS (via CocoaPods)
- Android: using latest Google Play Service for Android (via gradle)
To install this plugin, follow the Command-line Interface Guide. You can use one of the following command lines:
cordova plugin add cordova-admob
cordova plugin add https://github.com/appfeel/admob-google-cordova.git
To use in Phonegap Build, place the following tag in your config.xml
file:
<gap:plugin name="phonegap-admob" source="npm"/>
To start showing ads, place the following code in your onDeviceReady
callback. Replace corresponding id's with yours:
Note: ensure you have a proper AdMob and tappx accounts and get your banner id's.
function onDeviceReady() {
document.removeEventListener('deviceready', onDeviceReady, false);
// Set AdMobAds options:
admob.setOptions({
bannerAdId: "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB", // Required
interstitialAdId: "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII", // Optional
autoShowBanner: true, // Optional
autoShowRInterstitial: false, // Optional
autoShowRewarded: false, // Optional
tappxIdiOS: "/XXXXXXXXX/Pub-XXXX-iOS-IIII", // Optional
tappxIdAndroid: "/XXXXXXXXX/Pub-XXXX-Android-AAAA", // Optional
tappxShare: 0.5 // Optional
});
// Start showing banners (atomatic when autoShowBanner is set to true)
admob.createBannerView();
// Request interstitial ad (will present automatically when autoShowInterstitial is set to true)
admob.requestInterstitialAd();
// Request rewarded ad (will present automatically when autoShowRewarded is set to true)
admob.requestRewardedAd();
}
document.addEventListener("deviceready", onDeviceReady, false);
If you don't specify tappxId, no tappx requests will be placed (even if you specify a tappxShare). See Tappx configuration for more detailed info.