GithubHelp home page GithubHelp logo

leothenerd / cordova-admob-pro Goto Github PK

View Code? Open in Web Editor NEW

This project forked from floatinghotpot/cordova-admob-pro

0.0 2.0 0.0 32.14 MB

Powerful Ad Plugin for Google AdMob and DFP. Easy use, show mobile Ad with single line of JavaScript. Stable and up to date with latest SDK. Compatible with Cordova CLI, PhoneGap Build, Intel XDK/Crosswalk, Google ChromeApp, IBM Worklight.

License: MIT License

Java 11.62% Objective-C 54.91% C++ 3.46% C# 19.90% JavaScript 4.02% HTML 6.09%

cordova-admob-pro's Introduction

AdMob Plugin Pro

Quick Demo

# 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

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
		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 a 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 full screen Ad? 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, and ref in your index.html.

Features

Platforms supported:

  • Android
  • iOS
  • Windows Phone

Maximize your revenue with mediation adapters:

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

How to use?

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

If use other tools or online build services, see:

Notice:

  • Cordova team announce that the plugin registry is being migrated to npm, and recommended name rule is: cordova-plugin-xxx
  • The plugin id in old cordova registry is com.google.cordova.admob, and now in npm is cordova-plugin-admobpro
  • Read: Difference of com.google.cordova.admob and cordova-plugin-admobpro
  • 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

Quick start with cordova CLI

	# 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

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

Javascript API Overview

Methods:

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

// use interstitial
prepareInterstitial(adId/options, success, fail);
showInterstitial();

// set default value for other methods
setOptions(options, success, fail);

Detailed Wiki

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

Screenshots

iPhone Banner iPhone Medium Rect
ScreenShot ScreenShot
iPad Medium Rect iPad SkyScraper
ScreenShot ScreenShot
iPad interstitial Any given X,Y:
ScreenShot ScreenShot
Android Banner Android Medium Rect
ScreenShot ScreenShot
Android Interstitial
ScreenShot

Tips

Some tips from recent stat data, FYI.

  • Using AdMob Plugin Pro, higher and more stable fill rate.
  • Using Interstitial, 5-10 times profit than banner Ad.
  • Using SMART_BANNER, avoid using BANNER or FULL_BANNER.

See Also

Ad PluginPro series for the world leading Mobile Ad services:

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

If use in commercial project and need email/skype support, please buy a license, you will be supported with high priority.

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

cordova-admob-pro's People

Contributors

floatinghotpot avatar

Watchers

Leo Chang avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.