1.0.2 • Published 7 years ago

cordova-plugin-audiencenetwork v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

Cordova Plugin for Facebook Audience Network

Quick Start

Install

cordova plugin add cordova-plugin-audiencenetwork

Example Code

Step 1: Prepare your Facebook Audience Network Placement Id for your app, create it in Facebook Developers website

var ad_units = {
	ios: {
		banner: 'your_ad_place_id',
		interstitial: 'your_ad_place_id',
    nativeAd: 'your_ad_place_id'
	},
	android: {
		banner: 'your_ad_place_id',
		interstitial: 'your_ad_place_id',
    nativeAd: 'your_ad_place_id'
	}
};

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

// set your hashed device id if testing on device (optional)
if (AudienceNetwork) AudienceNetwork.setOptions({
	isTesting: true,
	deviceHash: 'copy_your_hash_id_from_console_here'
});

Step 2: Create a banner with single line of javascript

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

Or, show the banner Ad in some other way:

// or, show a default banner at bottom
if (AudienceNetwork) AudienceNetwork.createBanner( {
	adId: adId.banner,
	position: AudienceNetwork.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 (AudienceNetwork) AudienceNetwork.prepareInterstitial({ adId: adid.interstitial, autoShow: false });

// show the interstitial later, e.g. at end of game level
if (AudienceNetwork) AudienceNetwork.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();

// for native ad
createNativeAd(adId, success, fail);
removeNativeAd(adId);
setNativeAdClickArea(adId,x,y,w,h);

Full Example Code

Check the test/index.html.

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago