vungle.init()

Type Function
Return value none
Revision Current Public Release (2017.3135)
Keywords ads, advertising, Vungle
See also vungle.load()
vungle.show()
vungle.*

Overview

vungle.init() initializes the Vungle plugin. This call is required and must be executed before making other Vungle calls such as vungle.load() or vungle.show().

Syntax

vungle.init( providerName, initParams [, adListener] )
providerName (required)

String. String value of "vungle".

initParams (required)

String. String containing your Vungle app ID plus one or more placement IDs, where each element is separated by a comma. For example "[YOUR_VUNGLE_APP_ID],[PLACEMENT_ID_1],[PLACEMENT_ID_2]".

adListener (optional)

Listener. The function or table that will handle adsRequest lifecycle events from the Vungle plugin.

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 )