startapp.show()

类型 函数
返回值
修订版 发行版 2024.3703
关键词 广告、宣传、StartApp、show
另请参阅 startapp.load()
startapp.*

概述

显示 StartApp 横幅广告、插屏广告、积分墙广告、视频广告或激励视频广告。

需注意之处

对于横幅广告,您必须先通过 startapp.load() 加载广告,并确认其已准备好显示。

语法

startapp.show( adType [, params] )
adType (必需)

String. 要显示的广告类型。有效值包括 "video""offerwall""interstitial""rewardedVideo""banner"

params (可选)

Table. 包含广告附加参数的表,有关详细信息,请参阅下一部分。

参数参考

params 表包括用于该广告的参数。

adTag (可选)

String. 标记只是附件到任一广告的一免费式字符串标识符。通过找到适合的广告与用户完美广告观看体验之间的平衡,广告标记将帮助您优化盈利。例如,如果您在应用程序的不同位置嵌入了两个插屏广告,您可以给每一个广告赋予不同的标记,其中一个是“Level1Complete”,另一个是“AfterScoresBoard”,然后您可以监控哪个位置转换效果更佳并从用户那儿获得更多参与。默认值为 nil。

yAlign (可选)

String. 仅适用于横幅广告,指定横幅在屏幕上的 y 轴位置。有效位置值是“top”或“bottom”。默认值为“bottom”。

bannerType (可选)

String. 仅适用于横幅广告,指定横幅的类型。有效类型值有:"automatic" - 自动选择下面列出的两个类型中最合适的横幅。"standard" - 一个标准(二维)横幅。"threed" - 一个三维旋转横幅。

示例

local startapp = require( "plugin.startapp" )

local function adListener( event )
    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.provider )
        -- Load an StartApp ad
        startapp.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 )
    elseif ( event.phase == "displayed" ) then  -- The ad was displayed/played
        print( event.type )
    elseif ( event.phase == "hidden" ) then  -- The ad was closed/hidden
        print( event.type )
    elseif ( event.phase == "clicked" ) then  -- The ad was clicked/tapped
        print( event.type )
    elseif ( event.phase == "reward" ) then  -- Rewarded video ad playback completed
        print( event.type )
    end
end

-- Initialize the StartApp plugin
startapp.init( adListener, { appId="Your App ID" } )

-- Show banner ad. no need to pre-load banner
startapp.show( "banner" , {
adTag = "menu top banner",
yAlign = "top",
bannerType = "standard"
} )

-- Sometime later, show an interstitial ad
if ( startapp.isLoaded( "interstitial" ) ) then
    startapp.show( "interstitial" )
end