Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
Admob Integration
-
Hi everyone.
I ve already use Monaca for a long time. Is there a way to integrate my app with admob?
Is Yes, How can I do this?Thank you
-
@pcamargo75 To utilize admob, you need this plugin: https://github.com/floatinghotpot/cordova-admob-pro
Then all you do is add this Javascript:
// This is a JavaScript file var admobid = {}; if( /(android)/i.test(navigator.userAgent) ) { admobid = { // for Android banner: 'ca-app-pub-XXXXXXX', // interstitial: 'ca-app-pub-XXXXXXX' }; } else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { admobid = { // for iOS banner: 'ca-app-pub-XXXXXXX', // interstitial: 'ca-app-pub-XXXXXXX' }; } else { admobid = { // for Windows Phone banner: 'ca-app-pub-XXXXXXX', // interstitial: 'ca-app-pub-XXXXXXX' }; } if(( /(ipad|iphone|ipod|android|windows phone)/i.test(navigator.userAgent) )) { document.addEventListener('deviceready', initApp, false); } else { initApp(); } function initApp() { if (! AdMob ) { alert( 'admob plugin not ready' ); return; } AdMob.createBanner( { adId: admobid.banner, isTesting: false, overlap: false, offsetTopBar: false, position: AdMob.AD_POSITION.BOTTOM_CENTER, bgColor: 'black' } ); /* AdMob.prepareInterstitial({ adId: admobid.interstitial, autoShow: true }); */ }
This is just for displaying a banner ad at the bottom. Check out the plugin docs for more information as you can do all sorts of stuff. Don’t forget you must register with AdMob and input your account ID.
You can also set
isTesting: true;
so you can do test ads.
-
Thanks, but how I can install this plugin?
-
@pcamargo75 What platform are you using? Monaca Cloud, CLI, Visual Studio?
-
Monaca Cloud
-
@pcamargo75 Free version or paid developer version?
-
Free Version
-
@pcamargo75 You won’t be able to. Only paid versions can do custom cordova plugins. If you upgrade, here is how you do it:
https://docs.monaca.io/en/manual/dependencies/custom_cordova_plugin/
-
Many thanks.
-
They do have monthly plans with no contract if cost is an issue: https://monaca.io/pricing.html