licensing.verify()

类型 函数
licensing.*
返回值
修订 版本 2024.3703
关键词 许可, 验证
另请参阅 licensing.init()

概述

启动许可证验证流程。

陷阱

如果目标商店与提供商不同,该函数将返回 false 并且不会调用监听器。您应该始终假设用户已通过验证,除非另有说明。

语法

licensing.verify( listener )
监听器 (必填)

监听器 用于处理许可证验证状态的监听器函数。发送到此监听器的属性与 许可事件 相对应。

示例

local licensing = require( "licensing" )

-- Initialize licensing
licensing.init( "google" )

local licensingListener = {}
function licensingListener:licensing( event )

    print( event.provider )    -- Provider for this licensing instance ("google")
    print( event.isVerified )  -- Boolean of true if license has been verified, otherwise false
    print( event.isError )     -- Boolean of true if there was an error during verification
    print( event.errorType )   -- Type of error: "configuration" or "network" (nil if no error)
    print( event.response )    -- Translated response from the licensing server
    print( event.expiration )  -- Expiration time of the cached license

    if ( event.isVerified ) then
        -- License successfully verified
        print( "Verified!" )
    else
        -- Failed to verify app from the Google Play store
        print( "Failed!" )
    end
end

-- Attempt to verify the license
licensing.verify( licensingListener )