Type Function Return value Number Revision Release 2024.3703 Keywords ads, advertising, AdMob, height See also admob.show() admob.*
Only applies to banner ads. Gets the height of a
admob.height()
local admob = require( "plugin.admob" ) -- Declare variable for storing banner height; this may change if device is rotated local bannerHeight -- AdMob listener function local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization -- Load an AdMob banner ad admob.load( "banner", { adUnitId="YOUR_ADMOB_AD_UNIT_ID" } ) elseif ( event.phase == "loaded" ) then if ( event.type == "banner" ) then -- Banner ad is loaded bannerHeight = admob.height() -- Get the loaded banner's height -- Show the banner ad with a 30 pixel gap between the screen bottom admob.show( "banner", { y = display.actualContentHeight - bannerHeight - 30 } ) end end end -- Initialize the AdMob plugin admob.init( adListener, { appId="YOUR_ADMOB_APP_ID" } )