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

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

Returns the platform ID 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`.

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

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

Returns the language set by the user on the platform. If the platform does not provide this data, it returns 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.

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

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.

```java
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.

```java
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.

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

#### Get All Games

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

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

#### Get Game By Id

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

```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, games) => {
        Debug.Log($"OnGetAllGamesCompleted, success: {success}, games:");

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

#### <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="danger" %}
The call to <mark style="color:orange;">Bridge</mark>.platform.<mark style="color:purple;">SendMessage</mark> with the parameter <mark style="color:orange;">PlatformMessage.GameReady</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.

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

<table><thead><tr><th width="194.59765625">Message</th><th width="310.61328125">Parameters</th><th>Description</th></tr></thead><tbody><tr><td>GameReady</td><td>No parameters</td><td>The game has loaded, all loading screens have passed, and the player can interact with the game.</td></tr><tr><td>InGameLoadingStarted</td><td>No parameters</td><td>Some loading inside the game has started. For example, when a level is loading.</td></tr><tr><td>InGameLoadingStopped</td><td>No parameters</td><td>Loading inside the game is finished.</td></tr><tr><td>PlayerGotAchievement</td><td>No parameters</td><td>The player has reached a significant milestone. For example, defeating a boss or setting a new record.</td></tr><tr><td>LevelStarted</td><td>Optional. Example: { "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>LevelCompleted</td><td>Optional. Example: { "world": "desert", "level": 1 }</td><td>Gameplay has completed. For example, the player won level.</td></tr><tr><td>LevelFailed</td><td>Optional. Example: { "world": "desert", "level": 1 }</td><td>Gameplay has failed. For example, the player lost level.</td></tr><tr><td>LevelPaused</td><td>Optional. Example: { "world": "desert", "level": 1 }</td><td>Gameplay has paused. Opened setings menu or used pause button</td></tr><tr><td>LevelResumed</td><td>Optional. Example: { "world": "desert", "level": 1 }</td><td>Gameplay has resumed. Returned from settings menu or hit unpause button</td></tr></tbody></table>

#### Is Audio Enabled <a href="#server-time" id="server-time"></a>

Check if the audio is turned on on the platform.

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

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

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

#### Pause

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

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

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

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

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

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

```java
Bridge.game.visibilityState
```

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

```csharp
// To track visibility state changes, subscribe to the event
private void Start()
{
    Bridge.game.visibilityStateChanged += OnGameVisibilityStateChanged;
}

private void OnGameVisibilityStateChanged(VisibilityState state)
{
    switch (state)
    {
        case VisibilityState.Visible:
            // The game tab is visible
            break;
        case VisibilityState.Hidden:
            // The game tab is hidden
            break;
    }
}
```

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