applovin.isLoaded()

Type Function
Return value Boolean
Revision 2017.3060
Keywords ads, advertising, AppLovin, isLoaded
See also applovin.show()
applovin.*

Overview

Checks to see if a AppLovin ad is already loaded. Returns true if an ad is loaded/ready, otherwise returns false.

Syntax

applovin.isLoaded( [isRewarded] )
isRewarded (optional)

Boolean. Set this to true to check if a rewarded video has loaded. If omitted or set to false, this function checks if a standard interstitial/video ad has loaded instead. Default is false. Note that you must enable "Rewarded Video" in the AppLovin developer portal to receive rewarded videos in your app.

Example

local applovin = require( "plugin.applovin" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.isError )
        -- Load an AppLovin ad
        applovin.load()

    elseif ( event.phase == "loaded" ) then  -- The ad was successfully loaded
        print( event.type )

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

-- Initialize the AppLovin plugin
applovin.init( adListener, { sdkKey="YOUR_SDK_KEY" } )

-- Sometime later, check if the ad is loaded
local isAdLoaded = applovin.isLoaded()
print( isAdLoaded )