Skip to content

Quick Start Example Code

floatinghotpot edited this page Oct 17, 2014 · 1 revision

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

var ad_units = {
	ios : "publisher_id_for_ios_xxx",
	android : "publisher_id_for_android_xxx"
};

// select the right Ad Id according to platform
var publisherId = ( /(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(MobFox) MobFox.createBanner( publisherId );

Or, show the banner Ad in some other way:

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

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

Step 4: Prepare an video Ad, and show it when needed

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

// show the interstitial later, e.g. at end of game level
if(MobFox) MobFox.showInterstitial();
Clone this wiki locally