# PokiSDK: GDevelop

Integrating the Poki SDK in GDevelop: the same five event moments as every engine, with GDevelop-specific setup.

[Source](https://developers.poki.com/guide/sdk-gdevelop)

## Integration outline

1.  **Set up the SDK** for GDevelop. Use GDevelop's built-in Poki export and events.
2.  **Signal loading:** fire `gameLoadingFinished()` when your game is done loading, so conversion to play is measured correctly.
3.  **Gameplay events:** fire `gameplayStart()` on the player's first input and every return to gameplay; `gameplayStop()` on every interruption (pause, level end, game over, menu).
4.  **Ads:** implement `commercialBreak()` at natural breaks before returning to gameplay, and `rewardedBreak()` for opt-in rewards. Mute audio and disable input during ads.
5.  **Test** with the [Poki Inspector](https://developers.poki.com/guide/inspector) to verify the event flow.

Event rules and the full order-of-events reference live in the [SDK overview](https://developers.poki.com/guide/sdk-overview).

This is the Poki Games SDK extension for [GDevelop](https://gdevelop.io/), the open-source, no-code game engine. Because GDevelop uses a visual event system instead of traditional code, the SDK is integrated entirely through actions, conditions, and expressions, with no scripting required. The Poki functions map to the JavaScript API as follows:

## Actions, conditions, and expressions

### Actions

```plaintext
Gameplay started          -- in JS: PokiSDK.gameplayStart()
Gameplay stopped          -- in JS: PokiSDK.gameplayStop()
Commercial break          -- in JS: PokiSDK.commercialBreak()
Rewarded break            -- in JS: PokiSDK.rewardedBreak()
Game loading finished     -- in JS: PokiSDK.gameLoadingFinished()
Create shareable URL      -- in JS: PokiSDK.shareableURL({})
Open external link        -- opens a URL via the Poki SDK
Move Poki Pill            -- repositions the Poki Pill on mobile
Measure event             -- sends an analytics event to Poki
```

### Conditions

```plaintext
Poki SDK is ready                      -- check if the SDK is initialized
Commercial break just finished playing -- fires once after a commercial break ends
Commercial break is playing            -- true while a commercial break is active
Rewarded break just finished playing   -- fires once after a rewarded break ends
Rewarded break is playing              -- true while a rewarded break is active
Should reward player                   -- true if the player watched the full rewarded ad
```

### Expressions

```plaintext
PokiGamesSDKHtml::LastShareableURL()        -- the last generated shareable URL
PokiGamesSDKHtml::URLParam("paramName")     -- read a URL param (supports gd-prefixed params)
```

## Install the extension

Open your GDevelop project, go to the **Project Manager**, and click **Create or search for new extensions**. Search for `Poki` and install the **Poki Games SDK** extension. Once installed, the extension's actions, conditions, and expressions are available in your event sheets.

Publishing to Poki GDevelop has a built-in Poki export option. When you're ready to publish, go to **File > Export > Poki** to generate a build specifically for the Poki platform. For more details, see the [GDevelop publishing guide for Poki](https://wiki.gdevelop.io/gdevelop5/publishing/poki/).

## Gameplay events

Use `gameplayStart()` to mark when players are playing your game (for example level start and unpause). Use `gameplayStop()` to mark when they aren't (for example level finish, game over, pause, or quit to menu). In GDevelop, add these as actions in your event sheet:

```plaintext
Condition: [Player clicks or taps to start]
Action:    Poki Games SDK > Gameplay started

Condition: [Player dies / level ends / game pauses]
Action:    Poki Games SDK > Gameplay stopped
```

## commercialBreak

Commercial breaks show video ads and should be triggered at natural breaks in your game. Throughout the game we recommend triggering a commercial break before every `gameplayStart()`, that is, whenever the player has shown intent to continue playing. It's important that the gameplay started event isn't fired during the ad, only after gameplay resumes.

```plaintext
Condition: [Player clicks "Play Again" or "Next Level"]
Action:    Poki Games SDK > Gameplay stopped
Action:    Poki Games SDK > Commercial break
```

Then handle the ad finishing:

```plaintext
Condition: Poki Games SDK > Commercial break just finished playing
Action:    Poki Games SDK > Gameplay started
Action:    [Your action to resume/start the game]
```

Important information about commercialBreaks Not every commercial break will trigger an ad. Poki's system decides when a player is ready for another ad, so feel free to signal as many commercial break opportunities as possible.

## rewardedBreak

Rewarded breaks let a player choose to watch a rewarded video ad in exchange for a benefit in the game (more coins, for example). When using a rewarded break, make it clear to the player beforehand that they're about to watch an ad.

```plaintext
Condition: [Player clicks "Watch Ad for Reward"]
Action:    Poki Games SDK > Gameplay stopped
Action:    Poki Games SDK > Rewarded break
```

Then handle the result using **both** conditions together:

```plaintext
Condition: Poki Games SDK > Rewarded break just finished playing
           AND Poki Games SDK > Should reward player
Action:    [Give the player their reward]
Action:    Poki Games SDK > Gameplay started
```

```plaintext
Condition: Poki Games SDK > Rewarded break just finished playing
           AND NOT Poki Games SDK > Should reward player
Action:    [No reward - player skipped or ad did not play]
Action:    Poki Games SDK > Gameplay started
```

About the rewardedBreak timer The rewarded break affects the timing of the commercial break: when a player interacts with a rewarded break, our system's ad timer is reset so they don't immediately see another ad.

## Final steps

### Disable sound and input during ads

Make sure audio and keyboard input are disabled during ads so the game doesn't interfere. You can use the `Commercial break is playing` and `Rewarded break is playing` conditions to detect when an ad is active:

```plaintext
Condition: Poki Games SDK > Commercial break is playing
           OR Poki Games SDK > Rewarded break is playing
Action:    [Mute audio / disable player input]
```

Alternatively, mute before requesting the break and unmute in the "just finished playing" event.

### Shareable URLs

You can create a shareable URL using a structure variable:

1.  Create a structure variable (for example `ShareParams`) with child variables like `id`, `type`, and `score`.
2.  Use the action **Poki Games SDK > Create shareable URL** and pass in `ShareParams`.
3.  Read the generated URL with the expression `PokiGamesSDKHtml::LastShareableURL()`.

To read URL parameters (including Poki's `gd`\-prefixed params), use the expression:

```plaintext
PokiGamesSDKHtml::URLParam("id")
```

This returns either the `gdid` param set on poki.com or the `id` param on the current URL.

### Poki Pill on mobile

If the Poki Pill overlaps your UI on mobile, reposition it with the **Move Poki Pill** action:

-   `TopPercent`: a value between `0` and `50`.
-   `TopPx`: an additional pixel offset.
-   The Poki default is `TopPercent = 0` and `TopPx = 20`.

### Upload and test your game in Poki for Developers

Congratulations, you've implemented the PokiSDK. Now upload your game to the [Poki Inspector](https://inspector.poki.dev/) and test it there. When you're happy with the implementation, send us a review request and we'll play the game. If you get stuck, reach out via Discord or `developersupport@poki.com`.

### Extension source and reference

For the full list of actions, conditions, and expressions, see the [GDevelop Poki SDK reference page](https://wiki.gdevelop.io/gdevelop5/extensions/poki-games-sdkhtml/).
