Skip to content

floatinghotpot/cordova-plugin-mopub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoPub Plugin Pro

Present MoPub Ads in Mobile App/Games natively from JavaScript.

Highlights:

  • Easy-to-use APIs. Display Ad with single line of Js code.
  • Support Banner, Interstitial Ad, and Video Ad.
  • One plugin supports both Android and iOS platform.
  • Multiple banner size, also support custom size.
  • Fixed and overlapped mode.
  • Auto fit on orientation change.
  • Actively maintained, prompt support.

Compatible with:

  • Cordova CLI, v3.5+

  • Intel XDK and Crosswalk, r1095+

  • IBM Worklight, v6.2+

  • MoPub Android SDK 4.9.0+

How to use?

If use with Cordova CLI:

cordova plugin add cordova-plugin-mopub

Quick Start Example Code

Step 1: Prepare your MoPub publisher Id for your app, create it in MoPub website

var ad_units = {
	ios : { 
		banner:"agltb3B1Yi1pbmNyDAsSBFNpdGUY8fgRDA",
		interstitial:"agltb3B1Yi1pbmNyDAsSBFNpdGUYsckMDA"
	},
	android : {
		banner:"agltb3B1Yi1pbmNyDAsSBFNpdGUY8fgRDA",
		interstitial:"agltb3B1Yi1pbmNyDAsSBFNpdGUYsckMDA"
	}
};

// select the right Ad Id according to platform
var adid = (/(android)/i.test(navigator.userAgent)) ? ad_units.android : ad_units.ios;

Step 2: Create a banner with single line of javascript

// it will display smart banner at top center, using the default options
if(MoPub) MoPub.createBanner( adid.banner );

Or, show the banner Ad in some other way:

// or, show a default banner at bottom
if(MoPub) MoPub.createBanner( {
	adId: adid.banner, 
	position:MoPub.AD_POSITION.BOTTOM_CENTER, 
	autoShow:true} );

Step 3: Prepare an interstitial, and show it when needed

// preppare and load ad resource in background, e.g. at begining of game level
if(MoPub) MoPub.prepareInterstitial( {adId:adid.interstitial, autoShow:false} );

// show the interstitial later, e.g. at end of game level
if(MoPub) MoPub.showInterstitial();

Javascript API Overview

Methods:

// set default value for other methods
setOptions(options, success, fail);
// for banner
createBanner(adId/options, success, fail);
removeBanner();
showBanner(position);
showBannerAtXY(x, y);
hideBanner();
// for interstitial
prepareInterstitial(adId/options, success, fail);
showInterstitial();

Detailed Documentation

The APIs, Events and Options are detailed documented.

Read the detailed API Reference Documentation English.

FAQ

If encounter problem when using the plugin, please read the FAQ first.

Full Example Code

This MoPub Plugin Pro offers the most flexibility and many options.

Check the [test/index.html] (https://github.com/floatinghotpot/cordova-plugin-mopub/blob/master/test/index.html).

Screenshots

iPhone Banner iPhone Interstitial
ScreenShot ScreenShot

Ad PluginPro series for the world leading Mobile Ad services:

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

If use in commercial project or need prompt support, please buy a license, you will be served with high priority.

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

About

Cordova/PhoneGap plugin for MoPub Ads

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published