applovin.isLoaded()

Type Function
Return value Boolean
Revision Release 2024.3703
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 and ready for display, otherwise returns false.

Syntax

applovin.isLoaded( adType )
adType (required)

String. One of the following values:

  • "banner"
  • "interstitial"
  • "rewardedVideo"
Note

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( "interstitial" )

    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( "interstitial" )
print( isAdLoaded )