Type Function Return value none Revision 2017.3060 Keywords ads, advertising, AdMob, show See also admob.hide() admob.load() admob.isLoaded() admob.*
Shows an AdMob interstitial, banner, or rewarded video ad that was previously loaded with admob.load().
Before attempting to show an ad, you must first load one via admob.load() and confirm it's ready to be shown. See the example below for basic usage details.
admob.show( adType [, params] )
Table. Table containing additional parameters for the specified ad type — see the next section for details.
The params
table includes parameters for the specified ad type.
String or Number. Only applies to banner ads, specifying the banner's y position on the screen. If you supply a string, valid position values are "top"
or "bottom"
. Alternatively, you can set a custom y position by specifying a number in content coodinates where 0
indicates the top edge of the screen or where a negative value specifies an offset from the bottom edge of the screen to the bottom edge of the banner. Default is "bottom"
.
String. Only applies to banner ads, specifying the background color of the smart banner. The value must be a hexadecimal RGB or ARGB value specified as "#RRGGBB"
or "#AARRGGBB"
. Default is nil
which will render the background as transparent.
local admob = require( "plugin.admob" ) -- AdMob listener function local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization -- Load an AdMob interstitial ad admob.load( "interstitial", { adUnitId="YOUR_ADMOB_AD_UNIT_ID" } ) end end -- Initialize the AdMob plugin admob.init( adListener, { appId="YOUR_ADMOB_APP_ID" } ) -- Sometime later, show the interstitial ad if ( admob.isLoaded( "interstitial" ) ) then admob.show( "interstitial" ) end