vungle.show()

Type Function
Return value Boolean
Revision Release 2024.3703
Keywords ads, advertising, Vungle
See also vungle.init()
vungle.load()
vungle.*

Overview

vungle.show() begins playing a placement full-screen video ad if one is cached and available for display.

This API returns a boolean true or false depending on the availability of a cached video ad.

Syntax

vungle.show( params )
params (required)

Table. A table that specifies properties for the ad request — see the next section for details.

Parameter Reference

The params table includes properties for the ad request.

placementID (required)

String. The placement ID of the ad to show.

isAutoRotation (required)

Boolean. If true (default), the video ad will rotate automatically with the device's orientation. If false, it will use the ad's preferred orientation. This is required for Android only — for iOS, it looks into the orientations key.

orientation (optional)

Number. For iOS only, the bitmask with the possible orientation values. Default is UIInterfaceOrientationMaskAll.

isSoundEnabled (optional)

Boolean. If true (default), sound will be enabled during video ad playback, subject to the device's sound settings. If false, video playback will begin muted. Note that the user can mute or un-mute sound during playback.

username (optional)

String. This parameter only applies to the incentivized ad unit type. When specified, it represents the user identifier that you wish to receive in a server-to-server callback that rewards the user for a completed video ad view.

alertTitle, alertText, alertContinue (optional)

String. You can customize a message to display to users when they attempt to close the incentivized video before completion. Note that this setting only applies to standard Vungle ads. For "Dynamic Template" ads, the same customization is available on the Vungle Dashboard.

immersive (optional)

String. For Android only, enables or disables immersive mode on KitKat+ devices.

large (optional)

String. For iOS only, draws larger buttons that control ad functions such as mute or close.

Example

local vungle = require( "plugin.vungle" )

local appID, placementID1, placementID2
if ( system.getInfo("platform") == "android" ) then
    appID = "YOUR_ANDROID_APP_ID"
    placementID1 = "YOUR_ANDROID_PLACEMENT_ID_1"
    placementID2 = "YOUR_ANDROID_PLACEMENT_ID_2"
else
    appID = "YOUR_IOS_APP_ID"
    placementID1 = "YOUR_IOS_PLACEMENT_ID_1"
    placementID2 = "YOUR_IOS_PLACEMENT_ID_2"
end

-- Vungle listener function
local function adListener( event )
 
    if ( event.type == "adInitialize" ) then  -- Successful initialization
        print( event.provider )
    end
end

-- Initialize the Vungle plugin
local initParams = appID .. "," .. placementID1 .. "," .. placementID2
vungle.init( "vungle", initParams, adListener )

local adShown = vungle.show( { placementId=placementID1, isSoundEnabled=true } )