1.2 Method: AdMob.setOptions()

Raymond Xie edited this page May 8, 2015 · 2 revisions

AdMob.setOptions(options)

Purpose: Set default values for other methods. All the option items are optional, will use default value if missing.

Params:

  • options, json object, mapping key to value.

key/value for param options:

  • adSize, string, banner Ad size, Default:'SMART_BANNER'. it can be: (see the screenshots for effects)
'SMART_BANNER', // recommended. auto fit the screen width, auto decide the banner height
'BANNER', 
'MEDIUM_RECTANGLE', 
'FULL_BANNER', 
'LEADERBOARD', 
'SKYSCRAPER', 
'CUSTOM', // custom banner size with given width and height, see param 'width' and 'height'
  • width, integer, banner width, valid when set adSize:'CUSTOM'. Default: 0
  • height, integer, banner height, valid when set adSize:'CUSTOM'. Default: 0
  • overlap, *boolean@, allow banner overlap webview, or else will push webview up or down to avoid overlap. Default:false
  • position, integer, position of banner Ad, Default:TOP_CENTER. Value can be one of:
AdMob.AD_POSITION.NO_CHANGE  	= 0,
AdMob.AD_POSITION.TOP_LEFT 		= 1,
AdMob.AD_POSITION.TOP_CENTER 	= 2,
AdMob.AD_POSITION.TOP_RIGHT 	= 3,
AdMob.AD_POSITION.LEFT 			= 4,
AdMob.AD_POSITION.CENTER 		= 5,
AdMob.AD_POSITION.RIGHT 		= 6,
AdMob.AD_POSITION.BOTTOM_LEFT 	= 7,
AdMob.AD_POSITION.BOTTOM_CENTER = 8,
AdMob.AD_POSITION.BOTTOM_RIGHT 	= 9,
AdMob.AD_POSITION.POS_XY 		= 10, // use the given X and Y, see params 'x' and 'y'
  • x, integer, x in pixels. Valid when overlap:true and position:AdMob.AD_POSITION.POS_XY. Default: 0
  • y, integer, y in pixels. Valid when overlap:true and position:AdMob.AD_POSITION.POS_XY. Default: 0
  • isTesting, boolean, set to true, to receiving test ad for testing purpose
  • autoShow, boolean, auto show interstitial ad when loaded, set to false if hope to control the show timing with prepareInterstitial/showInterstitial
  • orientationRenew, boolean, re-create the banner on web view orientation change (not screen orientation), or else just move the banner. Default:true.
  • adExtras, json object, set extra color style for Ad.
{
	color_bg: 'AAAAFF',
	color_bg_top: 'FFFFFF',
	color_border: 'FFFFFF',
	color_link: '000080',
	color_text: '808080',
	color_url: '008000'
}

Example Code:

var defaultOptions = {
	adSize: 'SMART_BANNER',
	width: 360, // valid when set adSize 'CUSTOM'
	height: 90, // valid when set adSize 'CUSTOM'
	position: AdMob.AD_POSITION.BOTTOM_CENTER,
	x: 0,		// valid when set position to POS_XY
	y: 0,		// valid when set position to POS_XY
	isTesting: true,
	autoShow: true
};
AdMob.setOptions( defaultOptions );
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.