-
Notifications
You must be signed in to change notification settings - Fork 0
general
Initialization, privacy/regulation settings, and the shared result/data types every ad module's callbacks use.
Initialization and cross-ad-type functions.
- levelplay_init
- levelplay_is_initialized
- levelplay_set_consent
- levelplay_set_metadata
- levelplay_set_dynamic_user_id
- levelplay_launch_test_suite
Shared data types used across every ad module.
This module includes a set of predefined constants that can be utilized for various purposes. Browse through the available constants to find values relevant to your needs and enhance the efficiency of your code.
Initializes the LevelPlay SDK. Call this once, before any other LevelPlay function. Requires
the extension's AndroidAppKey/iOSAppKey option to be set for the current platform (see
Extension Options).
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
levelplay_init(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call once initialization completes or fails. |
Returns:
LevelPlayError.Ok if the initialization request was
accepted, an error code if it was rejected outright (e.g. a missing app key) - in the rejected case
callback is never invoked.
Triggers:
Fires once, when the SDK finishes starting up (or fails to). Not fired if levelplay_init itself returned an error synchronously.
| Key | Type | Description |
|---|---|---|
| result | LevelPlayResult | The initialization outcome. |
Example:
levelplay_init(function(_result)
{
if (_result.success)
show_debug_message("LevelPlay initialized");
else
show_debug_message($"LevelPlay failed to initialize: {_result.error_message}");
});Returns whether levelplay_init has completed successfully.
Syntax:
levelplay_is_initialized()
Returns:
Sets whether the user provided consent, communicated to every mediated network that supports it. See Regulation Advanced Settings.
Syntax:
levelplay_set_consent(enable)
| Argument | Type | Description |
|---|---|---|
| enable | Boolean | Whether the user provided consent. |
Returns:
N/A
Sets a metadata key-value pair, forwarded to mediated networks that support it. See Regulation Advanced Settings.
Syntax:
levelplay_set_metadata(key, value)
| Argument | Type | Description |
|---|---|---|
| key | String | The metadata key to set. |
| value | String | The value to assign to the key. |
Returns:
N/A
Sets the Dynamic UserID, used by server-side reward callbacks to identify the user. See Dynamic UserID.
Syntax:
levelplay_set_dynamic_user_id(user_id)
| Argument | Type | Description |
|---|---|---|
| user_id | String | The value to set the Dynamic UserID to. |
Returns:
N/A
Launches the LevelPlay integration test suite, which lets you verify platform setup and preview ads for your configured networks. Does nothing if the current activity/view controller is unavailable. > [!IMPORTANT]
Never ship a build with a call to this left in.
Syntax:
levelplay_launch_test_suite()
Returns:
N/A
The lifecycle events an ad callback can fire with. Which subset of these a given ad type uses
is documented on that type's _load function (banner: _callback_subscribe).
These constants are referenced by the following functions:
| Member | Description |
|---|---|
Loaded |
The ad finished loading and is ready to show. |
LoadFailed |
The ad failed to load. LevelPlayResult.success is false for thisevent. |
Displayed |
The ad was displayed. Equivalent to an impression. |
DisplayFailed |
The ad failed to display. LevelPlayResult.success is false forthis event. |
Closed |
The ad view was closed. Interstitial and rewarded video only. |
Clicked |
The user clicked the ad. |
InfoChanged |
The ad info was updated - available when another ad has loaded with a higher CPM/rate. Interstitial and rewarded video only. |
Rewarded |
The user completed watching a rewarded video and should be rewarded. LevelPlayReward is populated for this event only. Rewarded video only. |
Expanded |
The banner was expanded to fullscreen. Banner only. |
Collapsed |
The banner was restored from fullscreen. Banner only. |
LeftApplication |
The user clicked the banner and was navigated out of the app. Banner only. |
Synchronous error codes returned by most functions in this extension. These describe why a call was rejected outright (e.g. before initialization, or with no ad loaded) - a failure reported by the SDK itself after a call was accepted instead arrives asynchronously via LevelPlayResult.
These constants are referenced by the following functions:
- levelplay_banner_create
- levelplay_init
- levelplay_interstitial_load
- levelplay_interstitial_set_callback
- levelplay_interstitial_show
- levelplay_rewarded_video_load
- levelplay_rewarded_video_set_callback
- levelplay_rewarded_video_show
| Member | Description |
|---|---|
Ok |
The call was accepted. |
NotInitialized |
levelplay_init has not completed successfully yet. |
AdNotReady |
The ad has not finished loading yet (or has already been shown). |
PlacementCapped |
The given placement has reached its daily cap. |
ActivityUnavailable |
The current Android activity / iOS view controller is not available. |
RootViewUnavailable |
Banner only - the root view was unavailable when the banner tried to attach itself. Discoverable only after levelplay_banner_create's synchronous return, so it is reported through the banner callback instead - see levelplay_banner_callback_subscribe. |
MissingAppKey |
The extension's AndroidAppKey/iOSAppKey option is not set for the currentplatform. |
InvalidHandle |
Interstitial/rewarded video only - handle is not a live handle from thematching _create function (or has already been destroyed). |
The uniform success/failure envelope delivered to every async callback in this extension.
error_message and sdk_error_code are both absent on success. sdk_error_code carries the SDK's
own ad-error code verbatim when the failure came from a LoadFailed/DisplayFailed ad-lifecycle
event; it is absent for every other event and for levelplay_init's own failures.
This struct is referenced by the following functions:
- levelplay_banner_callback_subscribe
- levelplay_init
- levelplay_interstitial_create
- levelplay_rewarded_video_create
| Member | Type | Description |
|---|---|---|
| success | Boolean | Whether the operation succeeded. |
| error_message | String | The SDK's own error message. Only present on failure. |
| sdk_error_code | Real | The SDK's raw ad-error code. Only present on a LoadFailed/DisplayFailed event that carried an SDK error object. |
Metadata about a specific ad instance/impression, delivered alongside most
LevelPlayCallbackEvent events. Mirrors the LevelPlay SDK's own ad-info object; fields
the SDK didn't supply for a given event are absent (width/height are 0 instead, since the SDK
always reports a size). On a LoadFailed event the SDK provides only the ad unit ID (no full ad-info
object exists yet) - unit_id is populated from that fallback and every other field is absent.
This struct is referenced by the following functions:
| Member | Type | Description |
|---|---|---|
| width | Real | The ad's width, in pixels. 0 if unknown. |
| height | Real | The ad's height, in pixels. 0 if unknown. |
| format | String | The ad format, as reported by the SDK. |
| network | String | The mediated network that served the ad. |
| unit_id | String | The ad unit ID. |
| unit_name | String | The ad unit's display name, as configured on the dashboard. |
| placement_name | String | The placement name the ad was requested for. |
| country | String | The country the impression is attributed to. |
| precision | String | The revenue precision, as reported by the SDK. |
| revenue | Real | The estimated revenue for this impression. |
The reward earned from a rewarded video ad, delivered with the LevelPlayCallbackEvent.Rewarded event. See Getting Started.
This struct is referenced by the following functions:
| Member | Type | Description |
|---|---|---|
| name | String | The reward's name, as configured for the ad unit on the dashboard. |
| amount | Real | The reward amount. |
YoYoGames 2026