简体   繁体   中英

Implementation of admob ads into a Cordova Javascript App

I recently signed up for an admob account in order to monetize my android app built using visual studio cordova(Javascript), but I was unable to get an sdk for javascript, I've surfed through the Internet but I couldn't find any help all the help am getting are for java(android and eclipse),but I stumbled upon this Click to view which I was unable get it working and also this Click to view which is for phonegap/java and some other plugins from npmjs which I couldn't implement(the steps were a little bit confusing for me) . Please if there any simpler implementation can you quide me through or point me to a source or sources(websites/video) I don't mind.

You can try with this plugin: https://github.com/appfeel/admob-google-cordova

To add the plugin:

cordova plugin add cordova-admob

To use it:

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
  });

  // Start showing banners (atomatic when autoShowBanner is set to true)
  admob.createBannerView();

  // Request interstitial (will present automatically when autoShowInterstitial is set to true)
  admob.requestInterstitialAd();
}

document.addEventListener("deviceready", onDeviceReady, false);

Try this plugin . I have tried it and it is working perfectly.

And here is how to use it:

admob.initAdmob("admob banner ID","admob interstitial ID");
var admobParam = new admob.Params();
admobParam.isTesting = false;
admob.showBanner(admob.BannerSize.SMART_BANNER, admob.Position.TOP_APP, admobParam);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM