inMobi.show()

Type Function
Return value none
Revision Release 2022.3683
Keywords ads, advertising, InMobi, show
See also inMobi.hide()
inMobi.load()
inMobi.isLoaded()
inMobi.*

Overview

Shows an InMobi ad which was previously loaded via inMobi.load().

Syntax

inMobi.show( placementID [, params] )
placementID (required)

String. The placement ID for the ad, retrieved from the InMobi developer portal. This is a numeric string and is listed in the InMobi developer portal under the label "Placement ID".

params (optional)

Table. Table containing positioning parameters for banner ads — see the next section for details.

Parameter Reference

The params table can include properties for positioning a banner ad. This does not apply to interstitial ads.

yAlign (optional)

String. Vertical alignment of the banner. Valid options are "top", "center", or "bottom". Default is "top".

Example

local inMobi = require( "plugin.inMobi" )

-- Pre-declare a placement ID
local placementID = "PLACEMENT_ID"

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        -- Load a banner ad
        inMobi.load( "banner", placementID )

    elseif ( event.phase == "failed" ) then  -- The ad failed to load
        print( event.type )
        print( event.placementId )
        print( event.isError )
        print( event.response )
    end
end

-- Initialize the InMobi plugin
inMobi.init( adListener, { accountId="YOUR_ACCOUNT_ID" } )

-- Sometime later, check if the ad is loaded
if ( inMobi.isLoaded( placementID ) ) then
    -- Show the ad
  inMobi.show( placementID, { yAlign="bottom" } )
end