appodeal.canShow()

类型 函数
返回值
版本 版本 2024.3703
关键词 广告,广告宣传,Appodeal,canShow
另请参阅 appodeal.show()
appodeal.*

概述

用于检查是否可为指定广告类型展示广告。

语法

appodeal.canShow( adUnitType, placement )
adUnitType (必需)

字符串. 您希望检查的广告类型。有效的值包括 "banner""interstitial""rewardedVideo"

placement (可选)

字符串. 您希望与广告相关联的位置。位置可以让您按广告展示之处来分离广告展示情况。您可以在 Appodeal 知识库 中阅读更多相关内容。

示例

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