/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

Push notification translation

Copy link

Push notification translation allows your users to receive notification messages in their preferred languages. Users can set up to four preferred languages. If messages are sent in one of those languages, the notification messages won’t be translated. If messages are sent in a language other than the preferred languages, the notification messages are translated into the user's first preferred language. In addition, the messages translated into other preferred languages are provided in the sendbird property of a notification message payload.

Note: A specific user's preferred languages can be set using the update a user API.

The following shows how to set the current user's preferred languages using the updateCurrentUserInfo() method.

val preferredLanguages = listOf("fr", "de", "es", "ko") // French, German, Spanish, Korean
SendbirdChat.updateCurrentUserInfo(preferredLanguages) { e ->
        if (e != null) {
                // Handle error.
        }

        // The current user's preferred languages have been updated successfully.
}

If successful, the following notification message payload is delivered to the current user's device.

{
    "message": {
        "token": "ad3nNwPe3H0:ZI3k_HHwgRpoDKCIZvvRMExUdFQ3P1...",
        "notification": {
            "title": "Greeting!",
            "body": "Bonjour comment allez vous"    // A notification message is translated into the first language listed in the preferred languages.
        },
        // ...

    },
    "sendbird": {
        "category": "messaging:offline_notification",
        "type": "User",
        "message": "Hello, how are you?",
        // ...

        "translations": {   // Translations of the message in the other three preferred languages.
            "fr": "Bonjour comment allez vous",
            "de": "Hallo wie geht es dir",
            "es": "Hola como estas"
        },
        // ...

    }
}