API
API
Lua

Defold Learn logo


poki_sdk

Version: stable

FUNCTIONS
poki_sdk.gameplay_start()
poki_sdk.gameplay_stop()
poki_sdk.commercial_break()
poki_sdk.rewarded_break()
poki_sdk.set_debug()
poki_sdk.capture_error()
poki_sdk.is_ad_blocked()
poki_sdk.shareable_url()
poki_sdk.get_url_param()
poki_sdk.measure()
poki_sdk.move_pill()
poki_sdk.get_device_info()
poki_sdk.get_user()
poki_sdk.get_token()
poki_sdk.login()
poki_sdk.open_external_link()
CONSTANTS
COMMERCIAL_BREAK_SUCCESS
COMMERCIAL_BREAK_START
REWARDED_BREAK_ERROR
REWARDED_BREAK_SUCCESS
REWARDED_BREAK_START

Functions

poki_sdk.gameplay_start()

poki_sdk.gameplay_start()

Signals that gameplay has started.

PARAMETERS

None


poki_sdk.gameplay_stop()

poki_sdk.gameplay_stop()

Signals that gameplay has stopped.

PARAMETERS

None


poki_sdk.commercial_break()

poki_sdk.commercial_break(callback)

Requests a commercial break. The callback reports START if an ad starts and SUCCESS when Poki's commercial-break promise resolves.

PARAMETERS

callback function
self object
The calling script instance
status number
One of the statuses: `poki_sdk.COMMERCIAL_BREAK_START`, `poki_sdk.COMMERCIAL_BREAK_SUCCESS`

poki_sdk.rewarded_break()

poki_sdk.rewarded_break(size,callback)

Requests a rewarded break. The size argument is optional and defaults to small. Call it as rewarded_break(callback) or rewarded_break(size, callback).

PARAMETERS

size string
Optional reward size. Accepted values are small, medium, and large. Defaults to small.
callback function
self object
The calling script instance
status number
One of the statuses: `poki_sdk.REWARDED_BREAK_ERROR`, `poki_sdk.REWARDED_BREAK_START`, `poki_sdk.REWARDED_BREAK_SUCCESS`

poki_sdk.set_debug()

poki_sdk.set_debug(is_debug)

Enables or disables Poki SDK debug mode.

PARAMETERS

is_debug boolean

poki_sdk.capture_error()

poki_sdk.capture_error(error)

Captures and reports an error to Poki.

PARAMETERS

error string

poki_sdk.is_ad_blocked()

poki_sdk.is_ad_blocked()

Deprecated: Poki no longer exposes ad-block detection. This compatibility function always returns false.

PARAMETERS

None

RETURNS

boolean Always false.

poki_sdk.shareable_url()

poki_sdk.shareable_url(params,callback)

Generates a shareable URL with the supplied parameters.

PARAMETERS

params table
String or number values to include in the generated URL.
callback function
self object
The calling script instance
url string
The generated shareable URL.

poki_sdk.get_url_param()

poki_sdk.get_url_param(key)

Returns the URL parameter value provided by Poki. The Defold bridge maps a null or undefined result to nil.

PARAMETERS

key string

RETURNS

stringnil The parameter value, or nil when the Poki result is null or undefined.

poki_sdk.measure()

poki_sdk.measure(category,what,action)

Sends a custom analytics event to Poki. Use start/complete/fail for progress, visible/interact for offer and UI engagement, or a custom action for other events. Do not duplicate commercial or rewarded ad playback and outcomes; Poki tracks those through the ad calls. The binding defaults omitted `what` and `action` to empty strings for compatibility.

PARAMETERS

category string
what string
nil
Optional event subject. Defaults to an empty string when omitted.
action string
nil
Optional event action. Defaults to an empty string when omitted.

poki_sdk.move_pill()

poki_sdk.move_pill(topPercent,topPx)

Moves the Poki pill to a different vertical position.

PARAMETERS

topPercent number
Position from the top in percent.
topPx number
Additional position offset in pixels.

poki_sdk.get_device_info()

poki_sdk.get_device_info()

PARAMETERS

None


poki_sdk.get_user()

poki_sdk.get_user(callback)

Retrieves the currently logged-in Poki user.

PARAMETERS

callback function
self object
The calling script instance
user table
nil
A table with username and avatar_url, or nil if no user is logged in.
error string
nil
The rejection message, or nil if the request completed normally.

poki_sdk.get_token()

poki_sdk.get_token(callback)

Retrieves the Poki auth token for the currently logged-in user.

PARAMETERS

callback function
self object
The calling script instance
token string
nil
The short-lived Poki auth token, or nil if no user is logged in.
error string
nil
The rejection message, or nil if the request completed normally.

poki_sdk.login()

poki_sdk.login(callback)

Prompts the player to log in to their Poki account.

PARAMETERS

callback function
self object
The calling script instance
success boolean
`true` if the login promise resolved, otherwise `false`.
error string
nil
The rejection message on failure, or nil on success.

poki_sdk.open_external_link()

poki_sdk.open_external_link(url)

Opens an external link in a new browser tab for user-initiated external navigation.

PARAMETERS

url string

Constants

COMMERCIAL_BREAK_SUCCESS

A commercial break finished or did not display.


COMMERCIAL_BREAK_START

A commercial break started.


REWARDED_BREAK_ERROR

A rewarded break failed or the reward should not be granted.


REWARDED_BREAK_SUCCESS

A rewarded break completed and the reward may be granted.


REWARDED_BREAK_START

A rewarded break started.