inMobi.load()

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

Overview

Preloads an InMobi ad. You can also call inMobi.isLoaded() to verify that the ad has been loaded and inMobi.show() to show it.

Syntax

inMobi.load( adUnitType, placementID [, params] )
adUnitType (required)

String. The type of ad according to the InMobi placement ID. Supported values are "banner" or "interstitial".

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 customization parameters for banner ads — see the next section for details.

Parameter Reference

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

width (optional)

Number. The width of the banner ad. InMobi returns a "best fit" ad for the banner dimensions specified. Default is 320.

height (optional)

Number. The height of the banner ad. InMobi returns a "best fit" ad for the banner dimensions specified. Default is 50.

autoRefresh (optional)

Boolean. Boolean value that determines if a banner ad should auto-refresh at a given interval (see refreshInterval below). Default is false.

refreshInterval (optional)

Number. The refresh interval, in seconds, for which banner ads should auto-refresh. This only applies if autoRefresh is set to true. Default is 60.

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 == "loaded" ) then  -- The ad was successfully loaded
        print( event.type )
        print( event.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" } )