applovinMax.isLoaded()

Type Function
Return value Boolean
Revision Release 2024.3703
Keywords ads, advertising, AppLovin, isLoaded, AppLovin Max
See also applovinMax.show()
applovinMax.*

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

applovinMax.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 applovinMax = require( "plugin.applovinMax" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.isError )
        -- Load an AppLovin ad
        applovinMax.load( "interstitial",  {iOSUnitId ="replace with your own", androidUnitId="replace with your own"} )

    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
applovinMax.init( adListener )

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