Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including cordova-plugin-admobpro with all npm packages installed. Try it out:

cordova-plugin-admobpro lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("cordova-plugin-admobpro/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

cordova-plugin-admobpro v2.49.0

Ultimate Cordova Plugin for Google AdMob and DFP to monetize hybrid apps. Show mobile Ad with single line of JavaScript. Compatible with Cordova CLI, PhoneGap Build, Intel XDK/Crosswalk, Google ChromeApp, Ionic, Meteor, etc.

AdMob Plugin Pro

Cordova / PhoneGap Plugin for Google Ads, including AdMob / DFP (doubleclick for publisher) and mediations to other Ad networks.


  1. Description
  2. History
  3. Features
  4. Demo
  5. Quick Start
  6. Installation
  7. Usage
  8. API
  9. Wiki and Docs
  10. Important Tips & Warning
  11. Video Tutorial
  12. Screenshots
  13. License
  14. Credits


This Cordova / PhoneGap plugin enables displaying mobile Ads with single line of javascript code. Designed for the use in HTML5-based cross-platform hybrid games and other applications.


Community-driven project. Designed and maintained by Raymond Xie since August 2014. It also features integration in AngularJS projects via [ngCordova] (

It was published to Cordova registry with id "" since Aug 2014, and has been downloaded more than 120,000 times. Now it's the No. 1 monetization plugin for Cordova community.


From May 2015, Cordova team announced the deprecation of Cordova registry, and suggest all plugins to be moved to npm repository. Now, the AdMob plugin is published to npm and renamed as "cordova-plugin-admobpro".


Platforms supported:

  • [x] iOS, via SDK v7.37.0 (see Release Notes)
  • [x] Android, via Android SDK (part of Google Play service, see Release Notes)
  • [x] Amazon-FireOS, via Android SDK (part of Google Play service)
  • [x] Windows Phone, via SDK v6.5.13 (see Release Notes)

Ad Types:

  • [x] Banner
  • [x] Interstitial (text, picture, video), highly recommended. :fire:
  • [x] Reward Video, highly recommended. :fire:
  • [ ] Native Ads (on roadmap)
  • [ ] Native Ads Advanced (on roadmap)

Mediation to other Ad networks:

  • [x] AdMob (built-in)
  • [x] DFP (DoubleClick for Publisher, built-in)
  • [x] Facebook Audience Network
  • [x] Flurry
  • [x] iAd
  • [x] InMobi
  • [x] Millennial Media
  • [x] MobFox

Quick Demo

Wanna quickly see the mobile ad on your simulator or device? Try the following commands.

    # install cordova CLI
    [sudo] npm install cordova -g

    # install a small utility to run all the commands for you
    [sudo] npm install plugin-verify -g

    # Demo 1: run admob demo with sample index.html
    plugin-verify cordova-plugin-admobpro

    # Demo 2/3: run admob demo in game powered by PIXI/phaser HTML5 engine
    plugin-verify admob-demo-game-pixi ios --landscape
    plugin-verify admob-demo-game-phaser ios --landscape

    # Demo 4: run admob demo in app powered by ionic/angular framework
    plugin-verify admob-demo-app-ionic ios --portrait

Quick start

    # create a demo project
    cordova create test1 com.rjfun.test1 Test1
    cd test1
    cordova platform add android
    cordova platform add ios

    # now add the plugin, cordova CLI will handle dependency automatically
    cordova plugin add cordova-plugin-admobpro

    # now remove the default www content, copy the demo html file to www
    rm -r www/*;
    cp plugins/cordova-plugin-admobpro/test/* www/;

    # now build and run the demo in your device or emulator
    cordova prepare; 
    cordova run android; 
    cordova run ios;
    # or import into Xcode / eclipse


  • If use with Cordova CLI:
cordova plugin add cordova-plugin-admobpro

cordova plugin add cordova-plugin-admobpro --save --variable PLAY_SERVICES_VERSION=16.0.0 --variable ADMOB_APP_ID="__your_admob_app_id___"

Or, if you see conflict when using Firebase, use this one instead:

cordova plugin add cordova-plugin-admobpro-firebase
  • If use with PhoneGap Build:
<preference name="android-build-tool" value="gradle" />
<preference name="phonegap-version" value="cli-7.1.0" />
<plugin name="cordova-plugin-admobpro" source="npm">
<variable name="PLAY_SERVICES_VERSION" value="16.0.0" />

If use other tools or online build services, see:

What's difference of these plugin IDs, which one shall I use ?

  • cordova-plugin-admob
  • cordova-plugin-admobpro
  • cordova-plugin-admobpro-firebase

Read: Difference of Plugin ID


  • If build locally using cordova-plugin-admobpro, to avoid build error, you need install some extras in Android SDK manager (type android sdk to launch it): android extra


Show Mobile Ad with single line of javascript code.

Step 1: Create Ad Unit Id for your banner and interstitial, in AdMob portal, then write it in your javascript code.

// select the right Ad Id according to platform
  var admobid = {};
  if( /(android)/i.test(navigator.userAgent) ) { // for android & amazon-fireos
    admobid = {
      banner: 'ca-app-pub-xxx/xxx', // or DFP format "/6253334/dfp_example_ad"
      interstitial: 'ca-app-pub-xxx/yyy'
  } else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { // for ios
    admobid = {
      banner: 'ca-app-pub-xxx/zzz', // or DFP format "/6253334/dfp_example_ad"
      interstitial: 'ca-app-pub-xxx/kkk'
  } else { // for windows phone
    admobid = {
      banner: 'ca-app-pub-xxx/zzz', // or DFP format "/6253334/dfp_example_ad"
      interstitial: 'ca-app-pub-xxx/kkk'

Step 2: Want cheap and basic banner? single line of javascript code.

// it will display smart banner at top center, using the default options
if(AdMob) AdMob.createBanner({
  adId: admobid.banner,
  autoShow: true });

Step 3: Want interstitial Ad to earn more money ? Easy, 2 lines of code.

// 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();

Or, you can just copy this admob_simple.js to your project, change the ad unit id to your own, and simply reference it in your index.html, like this:

<script type="text/javascript" src="admob_simple.js"></script>

Remember to remove isTesting:true if release for production.

AdMob Mediation Adapters

Optional mediations to increase your revenue (Read about AdMob Mediation Networks):

cordova plugin add cordova-plugin-admob-facebook
cordova plugin add cordova-plugin-admob-flurry
cordova plugin add cordova-plugin-admob-unityads
cordova plugin add cordova-plugin-admob-inmobi
cordova plugin add cordova-plugin-admob-mmedia
cordova plugin add cordova-plugin-admob-mobfox

Notice: If you want to add multiple mediations, please balance flexibility and binary size.



// use banner
createBanner(adId/options, success, fail);
showBannerAtXY(x, y);

// use interstitial
prepareInterstitial(adId/options, success, fail);
isInterstitialReady(function(ready){ if(ready){ } });

// use reward video
prepareRewardVideoAd(adId/options, success, fail);

// set values for configuration and targeting
setOptions(options, success, fail);

// get user ad settings
getAdSettings(function(inf){ inf.adId; inf.adTrackingEnabled; }, fail);


// onAdLoaded
// onAdFailLoad
// onAdPresent
// onAdDismiss
// onAdLeaveApp
document.addEventListener('onAdFailLoad', function(e){
    // handle the event

Wiki and Docs

Quick start, simply copy & paste:

API Reference:

Other Documentations:

Demo projects:

Video Tutorial

  • Using Cordova CLI to Add AdMob Plugin:


  • Run AdMob Demo App on Android:


More video by developers:


iPhone BanneriPhone Interstitial
Android BannerAndroid Interstitial


Some important tips, FYI.

  • [x] Why Google AdMob is recommended ?

Advertisement is main business and income source of Google, so clients are all around the world. Google is one of the most rialable partners for its high standard service.

  • High fill rate, nearly 100% all around world.
  • High quality Ad, bring high RPM.
  • Stable price, auto pay on time. Pay on every 20th next month.
  • [x] Strongly recommend Interstitial, more than 10 times profit than banner Ad.
Ad FormatBannerInterstitial
Click Rate< 1%3-15%
RPM (revenue per 1000 impression)US$ 0.5~4US$ 10~50
  • [x] Using SMART_BANNER to auto-fit the screen width, avoid using BANNER or FULL_BANNER (unless you are using DFP)

⚠:Remember Google's slogan: "Don't be evil". Invalid usage violating Google rules, may cause your AdMob account suspended !

  • AdMob publisher may NOT abuse or encourage abuse any Google products, including Google Play, YouTube or Blogger, incuding allow user downloading YouTube video, or embed YouTube video in your own apps.

  • Publishers may NOT click their own ads or use any means to inflate impressions and/or clicks artificially, including manual methods. Testing your own ads by clicking on them is not allowed.

More details, please read AdMob & AdSense policies


You can use the plugin for free, or you can also pay to get a license. IMPORTANT!!! Before using the plugin, please read the following content and accept the agreement. THIS WILL AVOID POTENTIAL PROBLEM AND DISPUTE.

There are 3 license options, fully up to you:

  1. Free and Open Source, no support
  2. Commercial, with email/skype support
  3. Win-win partnership, with forum support

If you hope to get a fully open source plugin (either need DIY, or hope to get full control on the code), use this open source one instead. Fork and pull request is welcome, but please mention it's derived source. Simply renaming then publishing to npm is forbidden. Open source project URL:

If use in commercial project, please get a license, or, you have monetized more than $1000 using this plugin, you are also required to either get a commercial license ($20). As a commercial customer, you will be supported with high priority, via private email or even Skype chat.

If you don't want to get a license as your apps may not earn too much, or you don't have a PayPal account to pay, here is a compromised option. You don't have to pay, we are also okay if just share 2 percent user traffic, so that we can cover our effort and focus on maintenance and online support. (We have maintained this project since Aug 2014, and closed more than 560 support issues)

Please read the License Agreement for details.


This project is created and maintained by Raymond Xie.

More Cordova/PhoneGap plugins by Raymond Xie, find them in plugin registry, or find them in npm.

Project outsourcing and consulting service is also available. Please contact us if you have the business needs.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free