Type Function
Return value String
Revision Release 2021.3646
Keywords ads, advertising, Appnext, createAd
See also appnext.loadAd()


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] )
adType (required)

String. The type of the ad. Possible values include "interstitial", "fullscreen", and "rewarded".

placementID (required)

String. The placement ID for the ad.

configParams (optional)

Table. A Lua table with configuration parameters for the created ad — see the next section for details.

Parameter Reference

The configParams table includes configuration parameters for the ad.

  • Certain parameters apply only to specific ad types, per the indicated sections.
  • Following creation of the ad, parameters can also be set and read via related appnext.set* and appnext.get* functions.


  • 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.
  • ButtonTextString indicating the install button's text. Default is "Install".
  • ButtonColorString indicating the install button's color as a 6-character hexadecimal color starting with #.
  • PreferredOrientationString 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".
  • BackButtonCanClose — Android only; boolean value indicating if the "Back" key can close the ad. Default is false.
  • MuteBoolean value which can mute the video which is played in the ad. Default is false.


  • CreativeTypeString which sets the creative type for the main section of the interstitial. Possible values are "managed", "video", or "static". Default is "managed".
  • SkipTextString which sets a custom text for the "skip" button. Default is "Skip".
  • AutoPlayBoolean which sets the video to auto-play. Default is true.

Full-Screen / Rewarded

  • ProgressTypeString which sets or hides the progress type. Possible values are "clock", "bar", "none", or "default". Default is "clock".
  • ProgressColorString indicating the progress bar and clock color as a 6-character hexadecimal color starting with #.
  • VideoLengthString indicating the video length of 15 or 30 seconds. Possible values are "15", "30", or "default". Default is "15".
  • ShowCloseBoolean 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.


  • RewardsTransactionIdString indicating a transaction ID per ad view. Make sure this is a unique rewards ID.
  • RewardsUserIdString indicating the user ID so that you will know which user to reward.
  • RewardsRewardTypeCurrencyString indicating the type of reward (life/credit/points).
  • RewardsAmountRewardedString indicating the amount of currency that was rewarded.
  • RewardsCustomParameterString 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 )

-- 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

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 )