Type Function Return value String Revision 2017.3060 Keywords ads, advertising, Appnext, createAd See also appnext.loadAd() appnext.*
This function is used to create an ad with a specific type and placement ID. If an ad with the same type and placement ID already exists, it will not be recreated.
appnext.createAd( adType, placementID [, configParams] )
String. The type of the ad. Possible values include "interstitial", "fullscreen", and "rewarded".
String. The placement ID for the ad.
Table. A Lua table with configuration parameters for the created ad — see the next section for details.
The configParams table includes configuration parameters for the ad.
Categories — A comma-delimited list of strings which set the preferred ad categories.Postback — Postback parameters (string) that will be posted to your server after user installs an app. Make sure to encode the values.ButtonText — String indicating the install button's text. Default is "Install".ButtonColor — String indicating the install button's color as a #.BackButtonCanClose — Android only; boolean value indicating if the "Back" key can close the ad. Default is false.Mute — Boolean value which can mute the video which is played in the ad. Default is false.CreativeType — String which sets the creative type for the main section of the interstitial. Possible values are "managed", "video", or "static". Default is "managed".SkipText — String which sets a custom text for the "skip" button. Default is "Skip".AutoPlay — Boolean which sets the video to true.ProgressType — String which sets or hides the progress type. Possible values are "clock", "bar", "none", or "default". Default is "clock".ProgressColor — String indicating the progress bar and clock color as a #.VideoLength — String indicating the video length of 15 or 30 seconds. Possible values are "15", "30", or "default". Default is "15".ShowClose — Boolean value which can display or hide the "close" button.CloseDelay — If the "close" button is shown, this delays its appearance by the set number value, in seconds.PreferredOrientation — String which sets the preferred orientation, assuming both landscape and portrait are supported by the application. Possible values are "automatic", "landscape", or "portrait". Default is "automatic".RewardsTransactionId — String indicating a transaction ID per ad view. Make sure this is a unique rewards ID.RewardsUserId — String indicating the user ID so that you will know which user to reward.RewardsRewardTypeCurrency — String indicating the type of reward (life/credit/points).RewardsAmountRewarded — String indicating the amount of currency that was rewarded.RewardsCustomParameter — String which allows you to pass any custom value/data.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 interstitialPlacementID
local fullscreenPlacementID
local rewardedPlacementID
local platform = system.getInfo( "platformName" )
if ( platform == "iPhone OS" ) then
interstitialPlacementID = "YOUR_IOS_INTERSTITIAL_PLACEMENT_ID"
fullscreenPlacementID = "YOUR_IOS_FULLSCREEN_PLACEMENT_ID"
rewardedPlacementID = "YOUR_IOS_REWARDED_PLACEMENT_ID"
elseif ( platform == "Android" ) then
interstitialPlacementID = "YOUR_ANDROID_INTERSTITIAL_PLACEMENT_ID"
fullscreenPlacementID = "YOUR_ANDROID_FULLSCREEN_PLACEMENT_ID"
rewardedPlacementID = "YOUR_ANDROID_REWARDED_PLACEMENT_ID"
end
local interstitialConfig = {
SkipText = "Close Ad",
CreativeType = "video"
}
local videoConfig = {
ShowClose = true,
CloseDelay = 5.5
}
local interstitialAdKey = appnext.createAd( "interstitial", interstitialPlacementID, interstitialConfig )
local fullscreenAdKey = appnext.createAd( "fullscreen", fullscreenPlacementID, videoConfig )
local rewardedAdKey = appnext.createAd( "rewarded", rewardedPlacementID )