chartboost.onBackPressed()

类型 函数
返回值 布尔值
修订 版本 2024.3703
关键词 广告, Chartboost, onBackPressed

概述

返回当按下“返回”键时广告是否已关闭。这应该在你的按键处理函数中实现(请参见下面的示例).

语法

chartboost.onBackPressed()

示例

local chartboost = require( "plugin.chartboost" )

-- Called when a key event has been received
local function onKeyEvent( event )

    if ( event.keyName == "back" and event.phase == "up" ) then
        local platformName = system.getInfo( "platformName" )
        if ( platformName == "Android" ) then
            if ( chartboost.onBackPressed() ) then
                -- Chartboost closed an active ad
                return true  -- Don't pass the event down the responder chain
            end
        end
    end

    -- IMPORTANT! Return false to indicate that this app is NOT overriding the received key
    -- This lets the operating system execute its default handling of the key
    return false
end

-- Add the key event listener
Runtime:addEventListener( "key", onKeyEvent )