How to add Google Admob ads to my app?


#1

How to add Google Admob ads to my app?


#2

here is what i’ve done n work. it works only in built app, not in scanner. you need to add this cordova plugin in ur build settings. you also need to register admob to get app-pub id from google.

[
{“source”:“AppGyver/phonegap-admob-plugin.git”}
]

and then add this code to ur index.js

document.addEventListener(‘deviceready’, function () {
admob.createBannerView({
‘publisherId’: ‘ca-app-pub-9604015245563184/6464053554’,
‘adSize’: admob.ADSIZE.SMARTBANNER
}, function () { // success
admob.requestAd({
‘isTesting’: false,
‘extras’: {
‘colorbg’: ‘e54747’,
‘colorborder’: ‘666666’,
‘colorlink’: ‘ffffff’,
‘colortext’: ‘ffffff’,","
‘color_url’: ‘ffcc33’
}
});
});
}, false);


#3

Thank you a lot.


#4

I added the repository to the build setting and added your code, but it still not showing the ads in my built app…


#5

normally it take several seconds to load ads. did you wait long enough?


#6

Yes I waited 10 minutes and more, but nothing happened. Maybe the problem comes because I installed the app from my Phone storage, not from the Google Play ?


#7

it doesn’t matter where u installed from, as long as it is built apk. how did u add these code to ur index.js? wanna share?


#8

Hey, i tried the plugin today. The successcallback for requestad works. But i am not seeing anything on the page. What could be wrong?

How do i know if my ad unit is serving ads?


#9

Does this still work?

  1. I registered our app at Admob and was assigned an Ad unit ID.

  2. I added the source in the build settings:
    [{https://github.com/Appgyver/phonegap-admob-pluin.git"}]

  3. I added your code to the apps’s JavaScript with our ca-app-pub number.

  4. I built the app on the Appgyver build service, downloaded and installed the apk on my test device. The app is broken.

  5. If I try to open index.html in Chrome it shows Uncaught syntax error: Unexpected token ILLEGAL for the publisherId in createBannerView,

Any thoughts?