• Stars
    star
    716
  • Rank 62,891 (Top 2 %)
  • Language
    Java
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔥 Cordova Plugin for Google AdMob, DFP, ADX. Easy monetization using mobile Ad, with single line of JavaScript. Compatible with Cordova CLI, Inoic, PhoneGap Build, etc.

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.

ScreenShot

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:

Ad Types:

  • Banner
  • Interstitial (text, picture, video), highly recommended. 🔥
  • Reward Video, highly recommended. 🔥
  • 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:

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): android extra

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:

<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.

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:

API Reference:

Other Documentations:

Demo projects:

Video Tutorial

  • Using Cordova CLI to Add AdMob Plugin:

Video

  • Run AdMob Demo App on Android:

Video

More video by developers:

Screenshots

iPhone Banner iPhone Interstitial
ScreenShot ScreenShot
Android Banner Android Interstitial
ScreenShot ScreenShot

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.

  • 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

License

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: https://github.com/floatinghotpot/cordova-plugin-admob

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.

Credits

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.

More Repositories

1

casino-server

🔥 An online poker game server powered by Redis, node.js and socket.io
JavaScript
965
star
2

socket.io-unity

socket.io client for Unity, power game client with node.js back-end
481
star
3

cordova-httpd

Embed tiny web server into Cordova with a plugin
Objective-C
282
star
4

cordova-plugin-admob

Basic Cordova Plugin for AdMob
C#
264
star
5

cordova-plugin-nativeaudio

The low latency audio plugin is designed to enable low latency and polyphonic audio from Cordova/PhoneGap applications, using a very simple and basic API.
Objective-C
234
star
6

coding-to-monetization

📖 From Coding to Monetization:Programmer's Financial Freedom Approach
189
star
7

cordova-plugin-sms

Plugin to operate SMS, send / list / intercept / delete / restore
Java
169
star
8

cordova-plugin-facebookads

Cordova/PhoneGap plugin for Facebook Audience Network Ads
Objective-C
65
star
9

protogen

CLI tool to parse protobuf .proto to C#, based on protobuf-net, works on Windows/Mac/Linux
XSLT
65
star
10

LiteCsvParser

A lite CSV reader and writer in C#, without any heavy dependency
C#
49
star
11

ipa-deploy

Deploy .IPA package to iOS device with a command line tool
Python
43
star
12

cordova-plugin-iad

Cordova plugin to support iAd on iOS
Objective-C
38
star
13

cordova-plugin-iflyspeech

Cordova plugin to support speech recognizer and synthesizer with iFlyTek voice cloud service
Objective-C
33
star
14

cordova-iad-pro

Cordova/PhoneGap Plugin for iAd with Banner and Interstitial
Objective-C
20
star
15

cordova-plugin-flurry

Cordova plugin to support Flurry (analytics and advertisement)
Objective-C
19
star
16

cordova-plugin-wifi

Cordova plugin to access mobile device Wifi info and operation
Java
19
star
17

admob-demo-game-phaser

Demo game for Cordova AdMob plugin, using phaser game engine
JavaScript
18
star
18

cordova-plugin-mopub

Cordova/PhoneGap plugin for MoPub Ads
Objective-C
17
star
19

raymud

Web-based MUD powered by nodejs and socket.io
CSS
16
star
20

gomoku

Gomoku, a HTML5 game working on PC and mobile device
JavaScript
13
star
21

hiquant

Quatitative trading framework and out-of-box toolset for assisting stock/fund investment
Python
13
star
22

magpie

General plugin framework for Cocos2d-x to call Cordova plugins
Shell
13
star
23

cordova-plugin-appleiap

Cordova plugin to support In-App Purchase on iOS
Objective-C
11
star
24

cordova-plugin-qq

Cordova plugin for Tencent QQ OpenSDK
Objective-C
11
star
25

admob-demo-app-ionic

JavaScript
11
star
26

UnityBatchBuild

Batch build toolset for Unity
Python
10
star
27

cordova-plugin-mmedia

Cordova/PhoneGap for Millennial Media Ad
Objective-C
8
star
28

cordova-smart-adserver

Cordova/PhoneGap Plugin for Smart Ad Server
Objective-C
8
star
29

cordova-mobfox-pro

Enhanced MobFox plugin for Cordova/PhoneGap. Banner, Interstitial and Video Ad. Support many other Ad network with server-side integration.
JavaScript
8
star
30

cordova-plugin-lianlianpay

Cordova/PhoneGap plugin for LianLianPay SDK
Java
7
star
31

plugin-verify

A simple utility to verify a Cordova plugin with its own test sample index.html
JavaScript
5
star
32

hotjs

A HTML5/javascript game/app framework written in javascript, in object-oriented way.
JavaScript
5
star
33

charset-convert

A command line tool to convert text file from one charset to another
JavaScript
5
star
34

cordova-plugin-paypalmpl

Cordova Plugin for PayPal MPL Library, not for new SDK.
Objective-C
5
star
35

mixin-pro

Improved javascript mixin to realize multiple inheritance for code reuse
JavaScript
4
star
36

cordova-admobsdk

Google Mobile Ads SDK for Cordova
Objective-C
3
star
37

cordova-admob-adapters

Cordova plugin for AdMob adapters
Objective-C
3
star
38

gomoku2

Gomoku HTML5 Game, newly written with HotJS Framework
JavaScript
3
star
39

cordova-plugin-ext

Extend the Cordova plugin base class with adapter interface. Plugin written based on this interface, can also be used for Unity, Cocos2d-X, and other frameworks.
Java
3
star
40

cordova-plugin-easyad

The easiest way to add AdMob/iAd to Cordova Apps
Objective-C
2
star
41

cordova-plugin-chartboost

Cordova plugin for Chartboost Ads
Objective-C
2
star
42

MagpieDemo

Demo Project for Magpie Framework, Call Cordova Plugins in Cocos2d-X Game
C++
2
star
43

knowledge-management

An Illustrated Guide to Knowledge Management
2
star
44

brackets-eclipse-theme

Eclipse light theme for Brackets
CSS
2
star
45

google-admob-sdk

Add Google Ads SDK to Cordova/PhoneGap project
Objective-C
2
star
46

webrpc

A reusable API server/client framework, running on socket.io
JavaScript
2
star
47

cordova-admob-xdk

Cordova AdMob Plugin for Intel XDK
C++
1
star
48

chinafund

Python
1
star
49

phonegap-jumprope

Jumping rope is cheap, portable, and burns more calories than you might think, try this mobile app
JavaScript
1
star
50

handycorp

A hybrid APP and its back-end, developed with javascript
JavaScript
1
star
51

testpaypalmpl

Demo project for cordova-plugin-paypalmpl
Java
1
star
52

admob-demo-game-pixi

Demo game for Cordova AdMob plugin, using PIXI game engine
JavaScript
1
star
53

cordova-facebook-sdk

Facebook SDK for Cordova
Objective-C
1
star
54

jump-rope

Jumping rope is cheap, portable, and burns more calories than you might think, try this mobile app
Java
1
star
55

cordova-plugin-vungle

Cordova Plugin for Vungle
Objective-C
1
star
56

cordova-plugin-appgrade

Cordova plugin for AppGrade
1
star
57

admob-demo-xdk

AdMob Demo for Intel XDK and Cordova Project
JavaScript
1
star
58

ajax-local

Some workaround to allow AJAX to load local resources
JavaScript
1
star