# Platform

The Platform module exposes host-platform data and lets the game report lifecycle events back to the host.

### When to use

Every game uses Platform. You'll typically need at least:

* **`platform.language`** — to localize text (read once after init).
* **`platform.sendMessage('game_ready')`** — to dismiss the platform loader (call once when the game is fully loaded and playable).

### Implementation order

1. **Required** — Read [`platform.language`](#language) and apply localization.
2. **Required** — Send [`platform.sendMessage('game_ready')`](#sending-a-message-to-the-platform) when the first playable frame is ready.
3. **Required** — React to [audio](#is-audio-enabled) and [pause](#pause) state events to mute or pause the game when the user switches tabs or the platform requests it.
4. **Recommended** — Send additional [`sendMessage`](#sending-a-message-to-the-platform) lifecycle events (`level_started`, `level_completed`, etc.).

#### Platform ID <a href="#platform-id" id="platform-id"></a>

Use this value only for platform-specific branches, such as passing platform-only options or handling different promotion APIs.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.id
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.platform.id
```

{% endtab %}

{% tab title="Construct 3" %}

```javascript
PlaygamaBridge.PlatformId
```

{% endtab %}

{% tab title="GDevelop" %}

```javascript
PlaygamaBridge::PlatformId()
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.platform.id
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_id()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.platform.id()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```typescript
bridge.platform.id
```

{% endtab %}

{% tab title="Scratch" %}

<figure><img src="/files/SLgDXyOwFlCOnYchsMfg" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

Returns the ID of the platform on which the game is currently running. Possible values: `playgama`, `vk`, `ok`, `yandex`, `facebook`, `crazy_games`, `game_distribution`, `playdeck`, `telegram`, `y8`, `lagged`, `msn`, `microsoft_store`, `poki`, `qa_tool`, `discord`, `gamepush`, `bitquest`, `huawei`, `jio_games`, `reddit`, `youtube`, `mock`, `xiaomi`.

#### Native SDK <a href="#native-sdk" id="native-sdk"></a>

Returns the original platform SDK object when Bridge exposes it. Use it only for platform-specific features that Bridge does not wrap.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.sdk
```

{% endtab %}
{% endtabs %}

#### Language <a href="#language" id="language"></a>

{% hint style="warning" %}
Read this after initialization and use it as the source language for your localization system.
{% endhint %}

Returns the language selected by the user on the host platform. If the platform does not provide a language, Bridge falls back to the browser language.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.language
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.platform.language
```

{% endtab %}

{% tab title="Construct 3" %}

```javascript
PlaygamaBridge.PlatformLanguage
```

{% endtab %}

{% tab title="GDevelop" %}

```javascript
PlaygamaBridge::PlatformLanguage()
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.platform.language
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_language()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.platform.language()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```typescript
bridge.platform.language
```

{% endtab %}

{% tab title="Scratch" %}

<figure><img src="/files/MrqLnXegLAeBlmxUFwiZ" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

If the platform provides user language data, this will be the language set by the user on the platform. If not, it will be the browser language.

Format: ISO 639-1. Example: `ru`, `en`.

#### URL Parameter <a href="#url-parameter" id="url-parameter"></a>

Read optional launch data passed through the platform URL. Use it for referral codes, deep links, invited-user context, or other launch parameters.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.payload
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.platform.payload
```

{% endtab %}

{% tab title="Construct 3" %}

```javascript
PlaygamaBridge.PlatformPayload
```

{% endtab %}

{% tab title="GDevelop" %}

```javascript
PlaygamaBridge::PlatformPayload()
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.platform.payload
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_payload()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.platform.payload()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```typescript
bridge.platform.payload
```

{% endtab %}

{% tab title="Scratch" %}

<figure><img src="/files/pEqlOYSmHtUKYGqyfHPo" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

The exact URL format is platform-specific:

| Platform    | URL Format                                                           |
| ----------- | -------------------------------------------------------------------- |
| VK          | <http://vk.com/game\\_i&#x64;**#your-info>\*\*                       |
| Yandex      | <http://yandex.com/games/app/game\\_i&#x64;**?payload=your-info>\*\* |
| Crazy Games | crazygames.com/game/game\_nam&#x65;**?payload=your-info**            |
| Mock        | site.com/game\_nam&#x65;**?payload=your-info**                       |

#### Domain Information <a href="#domain-information" id="domain-information"></a>

Returns the platform top-level domain when the host provides it. Use it for regional links, legal text, or domain-specific configuration.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.tld
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.platform.tld
```

{% endtab %}

{% tab title="Construct 3" %}

```javascript
PlaygamaBridge.PlatformTld
```

{% endtab %}

{% tab title="GDevelop" %}

```javascript
PlaygamaBridge::PlatformTld()
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.platform.tld
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_tld()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.platform.tld()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```typescript
bridge.platform.tld
```

{% endtab %}

{% tab title="Scratch" %}

<figure><img src="/files/pEqlOYSmHtUKYGqyfHPo" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

Returns `null` when no data is available; otherwise returns a TLD such as `com` or `ru`.

#### Is Get All Games Supported

Check this flag before showing a "More games" button that depends on `getAllGames`.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.isGetAllGamesSupported
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.platform.isGetAllGamesSupported
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/3YA3e5wVFMvf41noaX7S" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/FN71hugj10A7KdjbuubR" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

```javascript
Bridge.platform.is_get_all_games_supported
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_is_get_all_games_supported()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.platform.is_get_all_games_supported()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```typescript
bridge.platform.isGetAllGamesSupported
```

{% endtab %}
{% endtabs %}

#### Is Get Game By Id Supported

Check this flag before showing UI that links to a specific game through `getGameById`.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.isGetGameByIdSupported
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.platform.isGetGameByIdSupported
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/4jJXN3fPY3WgHvL1Pz3G" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/pk4EQ95ojnNUpXTuWlJM" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

```javascript
Bridge.platform.is_get_game_by_id_supported
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_is_get_game_by_id_supported()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.platform.is_get_game_by_id_supported()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
bridge.platform.isGetGameByIdSupported
```

{% endtab %}
{% endtabs %}

#### Get All Games

Returns platform-approved links to the developer's other games. Use it for a "More games" screen when the current platform supports cross-promotion.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.getAllGames()
    .then(data => {
        if (bridge.platform.id === "yandex") {
            for (const game of data) {
                console.log("AppID:", game["appID"])
                console.log("Title:", game["title"])
                console.log("URL:", game["url"])
                console.log("CoverURL:", game["coverURL"])
                console.log("IconURL:", game["iconURL"])
            }
        }
    })
```

{% endtab %}

{% tab title="Unity" %}

```csharp
private void Start()
{
    Bridge.platform.GetAllGames((success, games) => {
        Debug.Log($"OnGetAllGamesCompleted, success: {success}, games:");

        if (success) {
            switch (Bridge.platform.id)
            {
                case "yandex":
                    foreach (var game in games) {
                        Debug.Log($"App ID: {game["appID"]}");
                        Debug.Log($"Title: {game["title"]}");
                        Debug.Log($"URL: {game["url"]}");
                        Debug.Log($"Cover URL: {game["coverURL"]}");
                        Debug.Log($"Icon URL: {game["iconURL"]}");
                    }
                    break;
            }
        }
    });
}
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/V5wX4FGQcx2TB30D1w3U" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```json
{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-clicked","objectClass":"Button"}],"actions":[{"id":"get-all-games","objectClass":"PlaygamaBridge"}]},{"eventType":"block","conditions":[{"id":"on-get-all-games-completed","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"compare-two-values","objectClass":"System","parameters":{"first-value":"PlaygamaBridge.PlatformAllGamesCount","comparison":4,"second-value":"0"}}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"for","objectClass":"System","parameters":{"name":"\"games\"","start-index":"0","end-index":"PlaygamaBridge.PlatformAllGamesCount - 1"}}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"compare-two-values","objectClass":"System","parameters":{"first-value":"PlaygamaBridge.PlatformId","comparison":0,"second-value":"\"yandex\""}}],"actions":[{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"AppID:\" & PlaygamaBridge.PlatformAllGamesPropertyValue(loopindex(\"games\"), \"appID\")"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Title:\" & PlaygamaBridge.PlatformAllGamesPropertyValue(loopindex(\"games\"), \"title\")"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"URL:\" & PlaygamaBridge.PlatformAllGamesPropertyValue(loopindex(\"games\"), \"url\")"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Cover URL:\" & PlaygamaBridge.PlatformAllGamesPropertyValue(loopindex(\"games\"), \"coverURL\")"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Icon URL:\" & PlaygamaBridge.PlatformAllGamesPropertyValue(loopindex(\"games\"), \"iconURL\")"}}]}]}]}]}]}
```

</details>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/aY7oTJuS9z8mV4kxwvT5" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```json
{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button",""]}],"actions":[{"type":{"value":"PlaygamaBridge::PlatformGetAllGames"},"parameters":["",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnGetAllGamesCompleted"},"parameters":["",""]}],"actions":[],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"BuiltinCommonInstructions::CompareNumbers"},"parameters":["PlaygamaBridge::PlatformAllGamesCount()",">","0"]}],"actions":[{"type":{"value":"SetNumberVariable"},"parameters":["CurrentIndex","=","0"]}],"events":[{"type":"BuiltinCommonInstructions::Repeat","repeatExpression":"PlaygamaBridge::PlatformAllGamePropertiesCount()","conditions":[],"actions":[],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"BuiltinCommonInstructions::CompareStrings"},"parameters":["PlaygamaBridge::PlatformId()","=","\"yandex\""]}],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"AppID:\" + PlaygamaBridge::PlatformAllGamesPropertyValue(CurrentIndex, \"appID\")","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"Title:\" + PlaygamaBridge::PlatformAllGamesPropertyValue(CurrentIndex, \"title\")","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"URL:\" + PlaygamaBridge::PlatformAllGamesPropertyValue(CurrentIndex, \"url\")","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"cover URL:\" + PlaygamaBridge::PlatformAllGamesPropertyValue(CurrentIndex, \"coverURL\")","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"icon URL:\" + PlaygamaBridge::PlatformAllGamesPropertyValue(CurrentIndex, \"iconURL\")","\"info\"",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[],"actions":[{"type":{"value":"SetNumberVariable"},"parameters":["CurrentIndex","+","1"]}]}]}]}]}],"eventsCount":2,"actionsList":[],"actionsCount":0,"conditionsList":[],"conditionsCount":0}}
```

</details>
{% endtab %}

{% tab title="Godot" %}
{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
func _ready():
    Bridge.platform.get_all_games(funcref(self, "_on_get_all_games_completed"))

func _on_get_all_games_completed(success, games):
     print(success)

     match Bridge.platform.id:
         "yandex":
             for game in games:
                 print("App ID: " + str(game.appID))
                 print("Title: " + str(game.title))
                 print("URL: " + str(game.url))
                 print("Cover URL: " + str(game.coverURL))
                 print("Icon URL: " + str(game.iconURL))
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
func _ready():
    Bridge.platform.get_all_games(Callable(self, "_on_get_all_games_completed"))

func _on_get_all_games_completed(success, games):
     print(success)

     match Bridge.platform.id:
         "yandex":
             for game in games:
                 print("App ID: " + str(game.appID))
                 print("Title: " + str(game.title))
                 print("URL: " + str(game.url))
                 print("Cover URL: " + str(game.coverURL))
                 print("Icon URL: " + str(game.iconURL))
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_get_all_games()

// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_platform_get_all_games_callback" {
    if async_load[? "success"] {
        // your logic here
    }
}
```

{% endtab %}

{% tab title="Defold" %}

```lua
local bridge = require("bridge.bridge")

function init(self)
    bridge.platform.get_all_games(function (_, data)
        -- success
    end, function ()
        -- error
    end)
end
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
bridge.platform.getAllGames()
    .then(games => {
        if (bridge.platform.id === "yandex") {
            for (const game of games) {
                console.log("AppID:", game["appID"])
                console.log("Title:", game["title"])
                console.log("URL:", game["url"])
                console.log("CoverURL:", game["coverURL"])
                console.log("IconURL:", game["iconURL"])
            }
        }
    })
```

{% endtab %}
{% endtabs %}

#### Get Game By Id

Returns the platform-approved link and metadata for one game. Use it when you need to promote a specific title instead of a full list.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
let options = {}

if (bridge.platform.id === "yandex") {
    options = {
        gameId: "111111"
    }
}

bridge.platform.getGameById(options)
    .then(game => {
        if (bridge.platform.id === "yandex") {
            console.log("AppID:", game["appID"])
            console.log("Title:", game["title"])
            console.log("URL:", game["url"])
            console.log("CoverURL:", game["coverURL"])
            console.log("IconURL:", game["iconURL"])
            console.log("IsAvailable:", game["isAvailable"])
        }
    })
    
```

{% endtab %}

{% tab title="Unity" %}

```csharp
private void Start()
{
    var options = new Dictionary<string, object>();

    switch (Bridge.platform.id)
    {
        case "yandex":
            options.Add("gameId", "111111");
            break;
    }

    Bridge.platform.GetGameById(options, (success, game) => {
        Debug.Log($"OnGetGameByIdCompleted, success: {success}, game:");

        if (success) {
            switch (Bridge.platform.id)
            {
                case "yandex":
                    Debug.Log($"App ID: {game["appID"]}");
                    Debug.Log($"Title: {game["title"]}");
                    Debug.Log($"URL: {game["url"]}");
                    Debug.Log($"Cover URL: {game["coverURL"]}");
                    Debug.Log($"Icon URL: {game["iconURL"]}");
                    Debug.Log($"Is Available: {game["isAvailable"]}");
                    break;
            }
        }
    });
}    
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/yiR6NqNSNfltbL0VT8yg" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```json
{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-clicked","objectClass":"Button"}],"actions":[{"id":"add-action-parameter","objectClass":"PlaygamaBridge","parameters":{"key":"\"gameId\"","value":"\"111111\""}},{"id":"get-game-by-id","objectClass":"PlaygamaBridge"}]},{"eventType":"block","conditions":[{"id":"on-get-game-by-id-completed","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"is-last-action-completed-successfully","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"compare-two-values","objectClass":"System","parameters":{"first-value":"PlaygamaBridge.PlatformId","comparison":0,"second-value":"\"yandex\""}}],"actions":[{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"AppID:\" & PlaygamaBridge.PlatformGameByIdPropertyValue(\"appID\")"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Title:\" & PlaygamaBridge.PlatformGameByIdPropertyValue( \"title\")"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"URL:\" & PlaygamaBridge.PlatformGameByIdPropertyValue(\"url\")"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Cover URL:\" & PlaygamaBridge.PlatformGameByIdPropertyValue(\"coverURL\")"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Icon URL:\" & PlaygamaBridge.PlatformGameByIdPropertyValue(\"iconURL\")"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Is Available:\" & PlaygamaBridge.PlatformGameByIdPropertyValue(\"isAvailable\")"}}]}]}]}]}
```

</details>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/h6HcEuIHwWjFnxikndOC" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```json
{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button",""]}],"actions":[{"type":{"value":"PlaygamaBridge::AddActionParameter"},"parameters":["","\"gameId\"","\"111111\"",""]},{"type":{"value":"PlaygamaBridge::PlatformGetGameById"},"parameters":["",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnGetGameByIdCompleted"},"parameters":["",""]}],"actions":[],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::IsLastActionCompletedSuccessfully"},"parameters":["",""]}],"actions":[],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"BuiltinCommonInstructions::CompareStrings"},"parameters":["PlaygamaBridge::PlatformId()","=","\"yandex\""]}],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"App ID:\" + ToString(PlaygamaBridge::PlatformGameByIdPropertyValue(\"appID\"))","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"Title:\" + ToString(PlaygamaBridge::PlatformGameByIdPropertyValue(\"title\"))","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"URL:\" + ToString(PlaygamaBridge::PlatformGameByIdPropertyValue(\"url\"))","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"Icon URL:\" + ToString(PlaygamaBridge::PlatformGameByIdPropertyValue(\"iconURL\"))","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"Cover URL:\" + ToString(PlaygamaBridge::PlatformGameByIdPropertyValue(\"coverURL\"))","\"info\"",""]},{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"Is Available:\" + ToString(PlaygamaBridge::PlatformGameByIdPropertyValue(\"isAvailable\"))","\"info\"",""]}]}]}]}],"eventsCount":2,"actionsList":[],"actionsCount":0,"conditionsList":[],"conditionsCount":0}}
```

</details>
{% endtab %}

{% tab title="Godot" %}
{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
func _ready():
    var options

    options = {
        "gameId": "111111"
    }

    Bridge.platform.get_game_by_id(options, funcref(self, "_on_get_game_by_id_completed"))

func _on_get_game_by_id_completed(success, game):
    print(success)

    match Bridge.platform.id:
        "yandex":
            print("App ID: " + str(game.appID))
            print("Title: " + str(game.title))
            print("URL: " + str(game.url))
            print("Cover URL: " + str(game.coverURL))
            print("Icon URL: " + str(game.iconURL))
            print("Is Available: " + str(game.isAvailable))
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
func _ready():
    var options

    options = {
        "gameId": "111111"
    }

    Bridge.platform.get_game_by_id(options, Callable(self, "_on_get_game_by_id_completed"))

func _on_get_game_by_id_completed(success, game):
    print(success)

    match Bridge.platform.id:
        "yandex":
            print("App ID: " + str(game.appID))
            print("Title: " + str(game.title))
            print("URL: " + str(game.url))
            print("Cover URL: " + str(game.coverURL))
            print("Icon URL: " + str(game.iconURL))
            print("Is Available: " + str(game.isAvailable))
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="GameMaker" %}

```javascript
var options
switch playgama_bridge_platform_id() {
    case "yandex":
        options = {
            "gameId": "GAME_ID"
        }
        break
}

playgama_bridge_platform_get_game_by_id(json_stringify(options))

// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_platform_get_game_by_id_callback" {
    if async_load[? "success"] {
        // your logic here
    }
}
```

{% endtab %}

{% tab title="Defold" %}

```lua
local bridge = require("bridge.bridge")

function init(self)
    local options = {
        yandex = {
            gameId = "GAME_ID"
        }
    }

    bridge.platform.get_game_by_id(options, function (_, data)
        print("Game data: ", data)
    end, function ()
        -- error
    end)
end
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
async getGameById() {
    const gameId = this.gameIdInputField.string;
    try {
        const game = await bridge.platform.getGameById({ gameId });
        console.log(`onGetGameByIdCompleted, success: true, game:`);
        console.log(`App ID: ${game["appID"]}`);
        console.log(`Title: ${game["title"]}`);
        console.log(`URL: ${game["url"]}`);
        console.log(`Cover URL: ${game["coverURL"]}`);
        console.log(`Icon URL: ${game["iconURL"]}`);
    } catch (error) {
        console.error(`onGetGameByIdCompleted, success: false, error:`, error);
    }
}
```

{% endtab %}
{% endtabs %}

#### <img src="/files/qkRz0XouRMuwHLVog6j8" alt="" data-size="line"> Sending a Message to the Platform <a href="#sending-a-message-to-the-platform" id="sending-a-message-to-the-platform"></a>

Send lifecycle messages to the host platform. `game_ready` is required; the other messages help the platform understand gameplay state and can also drive Advanced Banners.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.sendMessage("game_ready")
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.platform.SendMessage(PlatformMessage.GameReady)
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/Ydy3fStXMw55ewRqmUW9" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/Z9cV6IaS2kMcTMlKPM3l" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.platform.send_message("game_ready")
```

To use constants for convenience:

```gdscript
Bridge.platform.send_message(Bridge.PlatformMessage.GAME_READY)
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_send_message("game_ready")
```

{% endtab %}

{% tab title="Defold" %}

```javascript
bridge.platform.send_message("game_ready")
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
sendGameReadyMessage() {
    bridge.platform.sendMessage(PLATFORM_MESSAGE.GAME_READY)
        .then(() => {
            console.log("Game ready message sent.");
        })
        .catch((error) => {
            console.error("Failed to send game ready message:", error);
        });
}
```

{% endtab %}

{% tab title="Scratch" %}

<figure><img src="/files/7ifSRQXodtJq131M7sib" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

<table><thead><tr><th width="225.51953125">Message</th><th>Parameters</th><th>Description</th></tr></thead><tbody><tr><td>game_ready</td><td>No parameters</td><td>The game has loaded, all loading screens have passed, the player can interact with the game.</td></tr><tr><td>in_game_loading_started</td><td>No parameters</td><td>Any loading within the game has started. For example, when a level is loading.</td></tr><tr><td>in_game_loading_stopped</td><td>No parameters</td><td>In-game loading has finished.</td></tr><tr><td>player_got_achievement</td><td>No parameters</td><td>The player reached a significant moment. For example, defeating a boss, setting a record, etc.</td></tr><tr><td>level_started</td><td>optional "world" and "level" example :<br>{"world":"desert","level":"1"}</td><td>Gameplay has started. For example, the player has entered a level from the main menu.</td></tr><tr><td>level_completed</td><td>optional "world" and "level" example :<br>{"world":"desert","level":"1"}</td><td>Gameplay has completed. For example, the player won level.</td></tr><tr><td>level_failed</td><td>optional "world" and "level" example :<br>{"world":"desert","level":"1"}</td><td>Gameplay has failed. For example, the player lost level.</td></tr><tr><td>level_paused</td><td>optional "world" and "level" example :<br>{"world":"desert","level":"1"}</td><td>Gameplay has paused. Opened settings menu or used pause button</td></tr><tr><td>level_resumed</td><td>optional "world" and "level" example :<br>{"world":"desert","level":"1"}</td><td>Gameplay has resumed. Returned from settings menu or hit unpause button</td></tr></tbody></table>

#### Is Audio Enabled

Returns whether the host platform currently allows game audio. Mute immediately when this value is `false` and listen for changes.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.isAudioEnabled
```

```javascript
// Listen for state changes
bridge.platform.on(bridge.EVENT_NAME.AUDIO_STATE_CHANGED, isEnabled => {
    console.log('Is audio enabled:', isEnabled);
});
```

{% endtab %}

{% tab title="Unity" %}

```csharp
Bridge.platform.isAudioEnabled
```

```javascript
// Listen for state changes
private void Start()
{
    Bridge.platform.audioStateChanged += OnAudioStateChanged;
}

private void OnAudioStateChanged(bool isEnabled)
{
    // audio state changed
}
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/PM8WeI2BXPDe8cKVwTRM" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/MzI6N7HcLGyWktCqSHy9" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.platform.is_audio_enabled
```

{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
# Listen for state changes
func _ready():
    Bridge.platform.connect("audio_state_changed", self, "_on_audio_state_changed")

func _on_audio_state_changed(is_enabled):
    print(is_enabled)
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
# Listen for state changes
func _ready():
    Bridge.platform.connect("audio_state_changed", Callable(self, "_on_audio_state_changed"))

func _on_audio_state_changed(is_enabled):
    print(is_enabled)
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_is_audio_enabled()
```

```javascript
// Listen for state changes

// via Async Social Event
if async_load[? "type"] == "playgama_bridge_platform_audio_state_changed" {
    if async_load[? "data"] {
        // audio enabled
    } else {
        // audio disabled
    }
}
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.platform.is_audio_enabled()
```

```javascript
// Listen for state changes
local bridge = require("bridge.bridge")

function init(self)
    bridge.platform.on("audio_state_changed", function (_, is_enabled)
        print("Is audio enabled: ", is_enabled)
    end)
end
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
bridge.platform.isAudioEnabled
```

```javascript
// Listen for state changes
bridge.platform.on(EVENT_NAME.AUDIO_STATE_CHANGED, this.onAudioStateChanged.bind(this));

onAudioStateChanged(isEnabled) {
    console.log("Is audio enabled: ", isEnabled);
}
```

{% endtab %}

{% tab title="Scratch" %}

<figure><img src="/files/HWNv2Wg2l6pEyP1WSLYS" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

#### Pause

Listen for host pause/resume requests. Pause gameplay, timers, and audio while `isPaused` is `true`.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
// Listen for state changes
bridge.platform.on(bridge.EVENT_NAME.PAUSE_STATE_CHANGED, isPaused => {
    console.log('Is paused:', isPaused);
});
```

{% endtab %}

{% tab title="Unity" %}

```javascript
// Listen for state changes
private void Start()
{
    Bridge.platform.pauseStateChanged += OnPauseStateChanged;
}

private void OnPauseStateChanged(bool isPaused)
{
    // pause state changed
}
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/6VFRpPFW5MOf4hBL8w60" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/T5sN6u9ii1e735spQ7qF" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}
{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
# Listen for state changes
func _ready():
    Bridge.platform.connect("pause_state_changed", self, "_on_pause_state_changed")

func _on_pause_state_changed(is_paused):
    print(is_paused)
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
# Listen for state changes
func _ready():
    Bridge.platform.connect("pause_state_changed", Callable(self, "_on_pause_state_changed"))

func _on_pause_state_changed(is_paused):
    print(is_paused)
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="GameMaker" %}

```javascript
// Listen for state changes

// via Async Social Event
if async_load[? "type"] == "playgama_bridge_platform_pause_state_changed" {
    if async_load[? "data"] {
        // paused
    } else {
        // resumed
    }
}
```

{% endtab %}

{% tab title="Defold" %}

```javascript
// Listen for state changes
local bridge = require("bridge.bridge")

function init(self)
    bridge.platform.on("pause_state_changed", function (_, is_paused)
        print("Is paused: ", is_paused)
    end)
end
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
// Listen for state changes
bridge.platform.on(EVENT_NAME.PAUSE_STATE_CHANGED, this.onPauseStateChanged.bind(this));

onPauseStateChanged(isPaused) {
    console.log("Is paused: ", isPaused);
}
```

{% endtab %}

{% tab title="Scratch" %}

<figure><img src="/files/3NJUD8mvFfIEkd8EDNqF" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

#### Server Time <a href="#server-time" id="server-time"></a>

Returns trusted UTC server time. Use it for daily rewards, cooldowns, or time-limited offers where local device time is not reliable.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.platform.getServerTime()
    .then(result => {
        console.log(result) // UTC time in milliseconds
    })
    .catch(error => {
        console.log(error)
    })
```

{% endtab %}

{% tab title="Unity" %}

```csharp
private void Start()
{
    Bridge.platform.GetServerTime(OnGetServerTimeCompleted);
}

private void OnGetServerTimeCompleted(DateTime? result)
{
    if (result.HasValue)
    {
        Debug.Log(result.Value); // UTC time
    }
}
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/VdXL25IYY4ezeQieFh14" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-clicked","objectClass":"Button"}],"actions":[{"id":"get-server-time","objectClass":"PlaygamaBridge"}]},{"eventType":"block","conditions":[{"id":"on-get-server-time-completed","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"has-server-time","objectClass":"PlaygamaBridge"}],"actions":[{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"PlaygamaBridge.ServerTime"}}]}]}]}
```

</details>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/v3zx3nRn4gE10fQKxFea" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button",""]}],"actions":[{"type":{"value":"PlaygamaBridge::GetServerTime"},"parameters":["",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnGetServerTimeCompleted"},"parameters":["",""]}],"actions":[],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::HasServerTime"},"parameters":["",""]}],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["ToString(PlaygamaBridge::ServerTime())","\"info\"",""]}]}]}],"eventsCount":2,"actionsList":[],"actionsCount":0,"conditionsList":[],"conditionsCount":0}}
```

</details>
{% endtab %}

{% tab title="Godot" %}
{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
func _ready():
    Bridge.platform.get_server_time(funcref(self, "_on_get_server_time_completed"))
	
func _on_get_server_time_completed(result):
    print(result) # UTC time in milliseconds
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
func _ready():
    Bridge.platform.get_server_time(Callable(self, "_on_get_server_time_completed"))

func _on_get_server_time_completed(result):
    print(result) # UTC time in milliseconds
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_platform_get_server_time()

// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_platform_get_server_time_callback" {
    if async_load[? "success"] {
        var server_time = async_load[? "data"]
    }
}
```

{% endtab %}

{% tab title="Defold" %}

```lua
local bridge = require("bridge.bridge")

function init(self)
	bridge.platform.get_server_time(function (_, data)
		print("Server time: ", data)
	end, 
	function ()
		-- error
	end)
end
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
getServerTime(){
    bridge.platform.getServerTime()
        .then((time) => {
            console.log("Server time: ", time);
        })
        .catch((error) => {
            console.error("Failed to get server time:", error);
        });
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.playgama.com/playgama/sdk/api/platform.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
