类型 函数 返回值 无 修订版 版本 2024.3703 关键字 广告,广告推广,Appnext,showAd 另请参阅 appnext.createAd() appnext.adIsLoaded() appnext.loadAd() appnext.*
此函数用于显示一个先前使用 appnext.createAd() 创建的广告,并且对于
appnext.showAd( adKey )
字符串. 为先前创建的广告返回的广告密钥。
local appnext = require( "plugin.appnext" )
local function adListener( event )
print( "Received " .. event.event .. " for " .. event.adKey .. " with message: " .. event.message )
end
-- Initialize the Appnext plugin
appnext.init( adListener )
-- Create your ads
local fullscreenPlacementID
local rewardedPlacementID
local platform = system.getInfo( "platformName" )
if ( platform == "iPhone OS" ) then
fullscreenPlacementID = "YOUR_IOS_FULLSCREEN_PLACEMENT_ID"
rewardedPlacementID = "YOUR_IOS_REWARDED_PLACEMENT_ID"
elseif ( platform == "Android" ) then
fullscreenPlacementID = "YOUR_ANDROID_FULLSCREEN_PLACEMENT_ID"
rewardedPlacementID = "YOUR_ANDROID_REWARDED_PLACEMENT_ID"
end
local fullscreenAdKey = appnext.createAd( "fullscreen", fullscreenPlacementID )
local rewardedAdKey = appnext.createAd( "rewarded", rewardedPlacementID )
-- Load your ads before showing
appnext.loadAd( fullscreenAdKey )
appnext.loadAd( rewardedAdKey )
-- Show full-screen video ad
if ( appnext.adIsLoaded( fullscreenAdKey ) ) then
appnext.showAd( fullscreenAdKey )
end