0

I am developed a simple mobile app in phonegap + Jquery Mobile. I want to add Google Admob to my app. The Admob coding is kept in external JavaScript file as admob.js.

I want to include this admob.js into my jquery mobile page. The onLoad function does not help. can anyone please help me out?

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
doodler9
  • 1
  • 1
  • you'll probably have to add a few examples of things you tried in order to receive any help. You can always update your question. Welcome to stack overflow, recommended reading: http://stackoverflow.com/help/how-to-ask – Dan Beaulieu Jun 26 '15 at 16:50
  • Just call your script from inside of the head of yout HTML file. – Joerg Jun 27 '15 at 05:35
  • @Joerg , thanks but that does not wrok. could you please provide any other solution? – doodler9 Jun 27 '15 at 06:14
  • check this http://stackoverflow.com/questions/14841790/any-way-to-display-admob-ads-or-other-ad-provider-in-pure-javascript – Sudhansu Choudhary Jun 29 '15 at 19:15

2 Answers2

0

Did you already tried this? https://api.jquery.com/jquery.getscript/

Not sure how much it will help you.

Thanks, Charles.

charles gomes
  • 2,145
  • 10
  • 15
0

You can take a look at https://github.com/appfeel/admob-google-cordova. You can use the plugin with phonegap like this:

cordova plugin add com.admob.google

If you are using Phonegap Build, in your config.xml:

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

Then you can use it as simple as (it also lets you create an optional (Tappx)[http://tappx.com account for backfill when there are no ads in your ads networks):

function onDeviceReady() {
  document.removeEventListener('deviceready', onDeviceReady, false);

  // Set AdMobAds options:
  admob.setOptions({
    publisherId:          "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB",  // Required
    interstitialAdId:     "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII",  // 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 (will present automatically when autoShowInterstitial is set to true)
  admob.requestInterstitial();
}

document.addEventListener("deviceready", onDeviceReady, false);
Miquel
  • 8,339
  • 11
  • 59
  • 82