百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

cordova-admob-pro

> 开发工具
开源

:fire: 适用于 Google AdMob、DFP 和 ADX 的 Cordova 插件。使用移动广告轻松实现盈利,只需一行 JavaScript 代码。与 Cordova CLI、Inoic 和 PhoneGap 兼容

719 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

:fire: 适用于 Google AdMob、DFP 和 ADX 的 Cordova 插件。使用移动广告轻松实现盈利,只需一行 JavaScript 代码。与 Cordova CLI、Inoic 和 PhoneGap 兼容

AdMob Plugin Pro

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

Contents

  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

Description

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.

History

Community-driven project. Designed and maintained by Raymond Xie since August 2014. It also features integration in AngularJS projects via [ngCordova] (http://www.ngcordova.com).

It was published to Cordova registry with id "com.google.cordova.admob" 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".

Features

Platforms supported:

  • iOS, via SDK v8.13.0 (see Release Notes)
  • Android, via Android SDK (part of Google Play service, see Release Notes)

Ad Types:

  • Banner
  • Interstitial (text, picture, video), highly recommended. :fire:
  • Reward Video, highly recommended. :fire:
  • Reward Interstitial (on roadmap)
  • Native Ads (not applicable to Cordova web apps)
  • Native Ads Advanced (not applicable to Cordova web apps)

Mediation to other Ad networks:

  • AdMob (built-in)
  • DFP (DoubleClick for Publisher, built-in)
  • Meta Audience Network
  • Flurry
  • InMobi
  • Millennial Media
  • 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

Installation

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

cordova plugin add cordova-plugin-admobpro --save --variable PLAY_SERVICES_VERSION=20.4.0 --variable ADMOB_ANDROID_APP_ID="__your_admob_android_app_id___" --variable ADMOB_IOS_APP_ID="__your_admob_ios_app_id___"

If use other tools or online build services, see:

  • Apache Cordova CLI, v7.0+ (How To ...)
  • Google Mobile Chrome App (How To ...)
  • Meteor (How To ...)
  • Ionic V1, Ionic V1 Demo
  • Ionic, Ionic Demo

Notice:

  • 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):

Usage

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 { // for ios
    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,
  position: AdMob.AD_POSITION.TOP_CENTER,
  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:

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.

API

Methods:

// use banner
createBanner(adId/options, success, fail);
removeBanner();
showBanner(position);
showBannerAtXY(x, y);
hideBanner();

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

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

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

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

Events:

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

Use AdMobPro with Ionic

Use with Capacitor:

$ npm install cordova-plugin-admobpro
$ npm install @awesome-cordova-plugins/admob-pro
$ ionic cap sync

Or, use with Cordova:

$ ionic cordova plugin add cordova-plugin-admobpro
$ npm install @awesome-cordova-plugins/admob-pro

Code for Angular:

import { AdMobPro } from '@awesome-cordova-plugins/admob-pro/ngx';
import { Platform } from '@ionic/angular';

constructor(private admob: AdMobPro, private platform: Platform ) { }

ionViewDidLoad() {
  this.admob.onAdDismiss()
    .subscribe(() => { console.log('User dismissed ad'); });
}

onClick() {
  let adId;
  if(this.platform.is('android')) {
    adId = 'YOUR_ADID_ANDROID';
  } else if (this.platform.is('ios')) {
    adId = 'YOUR_ADID_IOS';
  }
  this.admob.prepareInterstitial({adId: adId})
    .then(() => { this.admob.showInterstitial(); });
}

See more: https://ionicframework.com/docs/native/admob-pro

Wiki and Docs

Quick start, simply copy & paste:

  • Example Code
  • Complete Demo index.html

API Reference:

  • API Overview
  • How to Use Banner
  • How to Use Interstitial
  • How to Handle Ad Events
  • Chinese/中文文档

Other Documentations:

  • ChangeLog
  • Known issues & solutions/workarounds
  • FAQ
  • Notice for Android Proguard

Demo projects:

  • App demo for Ionic V1, by Jaive
  • App demo for Ionic, by Jaive
  • Game demo using phaser game engine
  • Game demo using PIXI game engine

Video Tutorial

  • Using Cordova CLI to Add AdMob Plugin:
  • Run AdMob Demo App on Android: More video by developers:
  • How to add Banner ads To Ionic apps with Admob Pro For android, by pointDeveloper
  • How To Add Banner Ads To Ionic 2 with AdMob Cordova Plugin, by pointDeveloper
  • How to add Interstitial Add on navigation for phonegap using JavaScript and AdMob Pro plugin, by pointDeveloper
  • Interesting Evolution of cordova-admob-pro (Gource Visualization), by Landon Wilkins

Screenshots

iPhone Banner iPhone Interstitial
Android Banner Android Interstitial

Tips

Some important tips, FYI.

  • 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.
  • Strongly recommend Interstitial, more than 10 times profit than banner Ad.
Ad Format Banner Interstitial
Click Rate < 1% 3-15%
RPM (revenue per 1000 impression) US$ 0.5~4 US$ 10~50
  • 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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaadmobadmob-plugincordovacordova-plugin

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具