inMobi.isLoaded()

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

Overview

Checks whether an ad is already loaded. Returns true if an ad is loaded/ready, otherwise returns false.

Syntax

inMobi.isLoaded( placementID )
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.

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
local isAdLoaded = inMobi.isLoaded( placementID )
print( isAdLoaded )