peanutlabs.init()

Type Function
Return value none
Revision Release 2024.3703
Keywords ads, advertising, Peanut Labs, init
See also peanutlabs.show()
peanutlabs.*

Overview

peanutlabs.init() initializes the Peanut Labs plugin.

Once initialized, you can show a survey using peanutlabs.show().

Syntax

peanutlabs.init( listener, params )
listener (required)

Listener. Listener function that will receive adsRequest events.

params (required)

Table. Table containing Peanut Labs initialization values — see the next section for details.

Parameter Reference

The params table includes parameters for PeauntLabs initialization.

userId (required)

String. The ID for the current user of your app.

appKey (required)

String. Your Peanut Labs app key, gathered from the PeauntLabs dashboard.

appId (required)

Number. Your Peanut Labs app ID, gathered from the PeauntLabs dashboard.

Example

local peanutlabs = require( "plugin.peanutlabs" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.provider )
    end
end

-- Initialize the Peanut Labs plugin
peanutlabs.init( adListener,
    {
        userId = "x1",
        appKey = "YOUR_APP_KEY",
        appId = 2222
    }
)