# Platform Parameters

At any time, you can retrieve values for specific parameters that you might use in your game, such as the user's browser language.

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

Identify the platform on which the game is currently running to customize features and settings accordingly.

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

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 native SDK of the platform.

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

#### <img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2F9BooaofCI33U9Np5oeif%2FFrame%203%20(1).png?alt=media&#x26;token=0750b56a-a069-4759-bda9-29951f06cd30" alt="" data-size="line"> Language <a href="#language" id="language"></a>

{% hint style="warning" %}
Check the language to display proper text labels.&#x20;
{% endhint %}

Get the language set by the user on the platform or the browser language if not provided by the platform, to localize game content.

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

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>

Embed auxiliary information into the game URL to pass additional data or settings when launching the game.

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

This parameter allows embedding auxiliary information into the game URL.

| 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>

Retrieve the top-level domain of the platform to handle domain-specific configurations and behavior.

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

Returns the top-level domain (TLD) of the platform. If there is no data – `null`. If the data is available – `com`, `ru`, etc.

#### Is Get All Games Supported

Verify whether the platform supports the `getAllGames` method to retrieve the correct links to the developer's other games.

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

#### Is Get Game By Id Supported

Verify whether the platform supports the `getGameById` method to retrieve the correct link to a specific game.

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

#### Get All Games

This method retrieves the correct links to the developer's other games.

<pre class="language-javascript"><code class="lang-javascript"><strong>bridge.platform.getAllGames()
</strong>    .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"])
            }
        }
    })
</code></pre>

#### Get Game By Id

This method retrieves the correct link to a specific game from the developer.

```javascript
const 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"])
        }
    })
    
```

#### <img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2F9BooaofCI33U9Np5oeif%2FFrame%203%20(1).png?alt=media&#x26;token=0750b56a-a069-4759-bda9-29951f06cd30" 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>

{% hint style="warning" %}
The call to <mark style="color:purple;">sendMessage</mark> with the parameter <mark style="color:orange;">game\_ready</mark> is mandatory!

Don't forget to implement it. Send this message only when the game is fully loaded.
{% endhint %}

Send predefined messages to the platform to trigger specific actions or events, such as signaling that the game is ready.

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

<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_pause</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

Check if the audio is turned on on the platform.

```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);
});
```

#### Pause

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

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

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

#### Current Visibility State <a href="#current-visibility-state" id="current-visibility-state"></a>

Check if the game tab is visible or hidden, and adjust game behavior accordingly, such as muting sound when hidden.

```javascript
bridge.game.visibilityState
```

```javascript
// Listen for visibility state changes
bridge.game.on(bridge.EVENT_NAME.VISIBILITY_STATE_CHANGED, state => {
    console.log('Visibility state:', state);
});
```

Returns the current visibility state of the game (the tab with the game). Possible values: `visible`, `hidden`.

{% hint style="info" %}
React to visibility state changes. For example, mute the game sound when `hidden` and unmute when `visible`.
{% endhint %}
