pollfish.init()

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

Overview

pollfish.init() initializes the Pollfish plugin. Once called, you must wait for an event.phase of "init" before loading a survey with pollfish.load().

Note

This call requires an API key which can be obtained from the Pollfish portal.

Syntax

pollfish.init( adListener, params )
adListener (required)

Listener. Listener function that will receive adsRequest events.

params (required)

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

Parameter Reference

The params table includes the following parameters for the Pollfish initialization.

apiKey (required)

String. Your API key from the Pollfish portal.

developerMode (optional)

Boolean. Setting this to true activates developer mode. Default is false.

  • true is used to help the developer test how Pollfish surveys will behave in the app (no paid surveys are presented).

  • false activates release mode. Use this mode for apps released to the app store (start receiving paid surveys).

requestUUID (optional)

String. A unique ID to identify a user. This ID is also passed through server-to-server callbacks.

Example

local pollfish = require( "plugin.pollfish" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        pollfish.load()
    end
    
end

-- Initialize the Pollfish plugin
pollfish.init( adListener, { apiKey="YOUR_API_KEY" } )