appodeal.isLoaded()

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

Overview

Checks if an ad has been loaded for the specified ad type. By default, Appodeal automatically caches ads in the background, so there is normally no need to load ads in advance of calling this method. However, automatic caching may be disabled when calling appodeal.init().

Syntax

appodeal.isLoaded( adUnitType )
adUnitType (required)

String. The type of ad you wish to check. Valid values include "banner", "interstitial", "video", and "rewardedVideo".

Example

local appodeal = require( "plugin.appodeal" )

local function adListener( event )

    if ( event.phase == "init" ) then  
        -- Successful initialization

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

-- Initialize the Appodeal plugin
appodeal.init( adListener, { appKey="YOUR_APP_KEY" } )

-- Some time later check if an ad is available
if appodeal.isLoaded("interstitial") then
    appodeal.show("interstitial")
end