11

On AdMob, there's no option for HTML5 apps anymore, and on AdSense, mobile apps (even those based on webview, explicitly mentioned) are banned.

How can I use Google advertising to monetize PhoneGap app (built with PhoneGap Build)?

trejder
  • 17,148
  • 27
  • 124
  • 216
Hayk Saakian
  • 2,036
  • 2
  • 18
  • 31
  • I would love to know the solution to this as well. I've been waiting a while for there to be some plugin for Phonegap Build but I've yet to find anything. – Fernker Jan 04 '13 at 20:06
  • same here ! how to monetize phonegap.build apps ? – Louis Oct 22 '13 at 08:05
  • http://phonegap.com/tool/ has a few ad providers, but I've never heard of them, so there you go – Hayk Saakian Oct 23 '13 at 04:11
  • Today Phonegap Build has changed their rules. See here: http://stackoverflow.com/a/27424661/513570 – Miquel Dec 11 '14 at 15:23
  • Are you sure that AdSense is still banned from mobile / WebView apps? I looked in the policy and found, that they support only certain WebViews?!?https://support.google.com/adsense/answer/48182 (under Technical requirements) – JepZ Feb 25 '17 at 12:19

2 Answers2

7

AdMob plugin was not available in PhoneGap Build before, as the old policy did not allow binary files submitted.

But now, they made a great change to their policy (http://phonegap.com/blog/2014/12/09/phonegap-build-new-features/), and now allow you to use the plugins in Cordova plugin registry.

To use Admob plugin in your app, just configure it in your config.xml:

<gap:plugin name="com.google.cordova.admob" source="plugins.cordova.io" />

To display a banner Ad:

if(AdMob) AdMob.createBanner( {
    adId:admobid.banner, 
    position:AdMob.AD_POSITION.BOTTOM_CENTER, 
    autoShow:true} );

To display a full screen Ad:

// preppare and load ad resource in background, e.g. at begining of game level
if(AdMob) AdMob.prepareInterstitial( {adId:admobid.interstitial, autoShow:false} );

// show the interstitial later, e.g. at end of game level
if(AdMob) AdMob.showInterstitial();

More detailed instructions and example code are documented at its github project homepage:

https://github.com/floatinghotpot/cordova-admob-pro

MikeX
  • 185
  • 1
  • 8
  • i assume this is android only? does it work on any other platforms by chance? – Hayk Saakian Dec 17 '14 at 01:54
  • 1
    i tested it on android and ios, both working. but not tested on windows phone yet as i don't use windows phone. – MikeX Dec 17 '14 at 03:06
  • this answer is outdates – Owen M Jul 19 '18 at 22:24
  • @OwenM Did you found the updated solution for this? If yes then let me know the link of it so I need to apply on my developed phone gap app. – Bhavin Thummar Jul 08 '19 at 09:40
  • @BhavinThummar I believe I had to install Google play services or something like that from Android Studio – Owen M Jul 08 '19 at 14:36
  • @OwenM Yes, you are right. If you have any code related google ads then please give any URL or something else so I can learn from that. – Bhavin Thummar Jul 09 '19 at 10:35
  • 1
    @BhavinThummar It seems I used cordova-plugin-admobpro, and I have the following code in a JS file that my Cordova HTML loads: document.addEventListener('deviceready', function() { if (AdMob && adsEnabled) { AdMob.createBanner({ adId: 'AD ID', autoShow: true, overlap: false }); } }, false); – Owen M Jul 09 '19 at 11:36
  • 1
    @OwenM Thank you for helping me. I will use this code and check google ad sense in my developed app. – Bhavin Thummar Jul 09 '19 at 11:39
2

PhoneGap builds native apps, so you'll have to use the Native AdMob SDK. There are guides on the web on how to do AdMob native implementation. But if you're more into plugins, check out the AdMob plugin for Cordova (Android | iOS).

Eric Leichtenschlag
  • 8,881
  • 1
  • 28
  • 28
  • 1
    I see what you mean, but if I use phonegap build that won't work. – Hayk Saakian Nov 21 '12 at 22:20
  • exactly, phonegap build compiles for all platform at once. The only interesting option was InMobi Js integration, but it's not working properly. – Louis Oct 22 '13 at 08:06
  • You could create two different projects in PhoneGap Build - one for iOS and one for Android, each using a different plugin. Annoying, but it works. – Rob Jul 10 '14 at 22:13