appodeal.canShow()

Type Function
Return value none
Revision Release 2022.3683
Keywords ads, advertising, Appodeal, canShow
See also appodeal.show()
appodeal.*

Overview

Checks if an ad can be shown for the specified ad type.

Syntax

appodeal.canShow( adUnitType, placement )
adUnitType (required)

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

placement (optional)

String. The placement you want the ad to be associated with. Placements allow you to separate ads impressions by places where it was shown. You can read more in Appodeal Knowledge base.

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" } )

-- Sometime later, check if an ad can be shown
if ( appodeal.canShow( "interstitial" ) ) then
    appodeal.show( "interstitial" )
end