defold/extension-poki-sdk/poki_sdk
Functions and constants for interacting with Poki SDK APIs
- GitHub: defold/extension-poki-sdk — pinned to
4.1.0(released while Defold 1.13.0 was current)- Pick a release from defold/extension-poki-sdk releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as poki_sdk from "poki_sdk"
- Pick a release from defold/extension-poki-sdk releases and add its Source code (zip) URL (or a packaged
Functions
poki_sdk.gameplay_start()poki_sdk.gameplay_stop()poki_sdk.commercial_break(callback: function)poki_sdk.rewarded_break(size: string | undefined, callback: function)poki_sdk.set_debug(is_debug: boolean)poki_sdk.capture_error(error: string)poki_sdk.is_ad_blocked(): booleanpoki_sdk.shareable_url(params: table, callback: function)poki_sdk.get_url_param(key: string): string | nilpoki_sdk.measure(category: string, what?: string | nil, action?: string | nil)poki_sdk.move_pill(topPercent: number, topPx: number)poki_sdk.get_device_info(): tablepoki_sdk.get_user(callback: function)poki_sdk.get_token(callback: function)poki_sdk.login(callback: function)poki_sdk.open_external_link(url: string)
poki_sdk.gameplay_start()
Signals that gameplay has started.
poki_sdk.gameplay_stop()
Signals that gameplay has stopped.
poki_sdk.commercial_break(callback: function)
Requests a commercial break. The callback reports START if an ad starts and SUCCESS when Poki's commercial-break promise resolves.
Parameters
callback:functionself:object— The calling script instancestatus:number— One of the statuses:poki_sdk.COMMERCIAL_BREAK_START,poki_sdk.COMMERCIAL_BREAK_SUCCESS
poki_sdk.rewarded_break(size: string | undefined, callback: function)
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 | undefined— Optional reward size. Accepted values are small, medium, and large. Defaults to small.callback:functionself:object— The calling script instancestatus:number— One of the statuses:poki_sdk.REWARDED_BREAK_ERROR,poki_sdk.REWARDED_BREAK_START,poki_sdk.REWARDED_BREAK_SUCCESS
poki_sdk.set_debug(is_debug: boolean)
Enables or disables Poki SDK debug mode.
Parameters
is_debug:boolean
poki_sdk.capture_error(error: string)
Captures and reports an error to Poki.
Parameters
error:string
poki_sdk.is_ad_blocked(): boolean
Deprecated: Poki no longer exposes ad-block detection. This compatibility function always returns false.
Returns
is_ad_blocked:boolean— Always false.
poki_sdk.shareable_url(params: table, callback: function)
Generates a shareable URL with the supplied parameters.
Parameters
params:table— String or number values to include in the generated URL.callback:functionself:object— The calling script instanceurl:string— The generated shareable URL.
poki_sdk.get_url_param(key: string): string | nil
Returns the URL parameter value provided by Poki. The Defold bridge maps a null or undefined result to nil.
Parameters
key:string
Returns
value:string | nil— The parameter value, or nil when the Poki result is null or undefined.
poki_sdk.measure(category: string, what?: string | nil, action?: string | nil)
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:stringwhat?: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(topPercent: number, topPx: number)
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(): table
Returns
value:table
poki_sdk.get_user(callback: function)
Retrieves the currently logged-in Poki user.
Parameters
callback:functionself:object— The calling script instanceuser: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(callback: function)
Retrieves the Poki auth token for the currently logged-in user.
Parameters
callback:functionself:object— The calling script instancetoken: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(callback: function)
Prompts the player to log in to their Poki account.
Parameters
callback:functionself:object— The calling script instancesuccess:boolean—trueif the login promise resolved, otherwisefalse.error:string | nil— The rejection message on failure, or nil on success.
poki_sdk.open_external_link(url: string)
Opens an external link in a new browser tab for user-initiated external navigation.
Parameters
url:string
Constants
poki_sdk.COMMERCIAL_BREAK_SUCCESS
A commercial break finished or did not display.
poki_sdk.COMMERCIAL_BREAK_START
A commercial break started.
poki_sdk.REWARDED_BREAK_ERROR
A rewarded break failed or the reward should not be granted.
poki_sdk.REWARDED_BREAK_SUCCESS
A rewarded break completed and the reward may be granted.
poki_sdk.REWARDED_BREAK_START
A rewarded break started.