Push notification with localized content

Not getting “translations” payload.
Application supports multiple languages (English, Spanish, etc) and looking for the push notification message content in the user specific language. I am able to send the language details to SendBird using “updateCurrentUserInfo” successfully but in response of push notification getting empty “translations” payload i.e.“translations”:{}.
Can someone help me to resolve issue?

Hi @Smita,

Welcome to the Sendbird Community. It looks like you raised this issue in a few places. In the future, we recommend only raising this in a single fashion so it doesn’t get confusing for our team.

Can you tell me how you’re passing translations to messages? Additionally, are you receiving the translation on the actual message via the SDK and just not in the payload of the notification

Hi @Tyler, Thanks for the response.
I referred API document :

As per this, need to update the user information only.
As of now I am not passing translations to user messages, just updated the user information with preferred language. For initial development looking for translated notification message.
Do I need to update any configurations to get translated notification message in “notification” along with “translations”?
Is it mandatory to send translated user message to receive translated notification message?

Hi @Smita,

Could you provide me with an example user where you set the preferred languages, and then didn’t get translated messages? Can you also provide me with a timestamp where you received a push notification that should have had translations but didn’t?

Hi @Tyler,
Here is code snippet and related response received from SendBird
SendBird.connect(id, token, (user, exception) → {
//Connecting to SendBird
});
//Once connection is successful, sending language details toSendBird
List preferredLanguages = new ArrayList<>();
preferredLanguages.add(“es”);
SendBird.updateCurrentUserInfo(preferredLanguages, new SendBird.UserInfoUpdateHandler() {
@Override
public void onUpdated(SendBirdException e) {
if (e != null) {
// Handle error.
Log.d(“Sendbird language”,":"+“Error in updating language”);
}

                    boolean isUpdatedSuccessfully = true;

                    for (String language : SendBird.getCurrentUser().getPreferredLanguages()) { // The getPreferredLanguages() returns a list of the current user's preferred languages.
                        if(!preferredLanguages.contains(language)) {
                            isUpdatedSuccessfully = false;
                            break;
                        }
                    }

                    if (isUpdatedSuccessfully) {
                        // The current user's preferred languages have been updated successfully.
                        Log.d("Sendbird language",":"+"languages have been updated successfully.");
                    }
                }
            });

//Completed required initialization. Now app is in background and received notification. (Using FirebaseMessagingService)

@Override
public void onMessageReceived(@NotNull RemoteMessage remoteMessage) {

 boolean isSendBirdPushNotification = remoteMessage.getData().containsKey("sendbird");
   if (isSendBirdPushNotification) {
         message = remoteMessage.getData().get("sendbird"); 

/* message = {“sqs_ts”:16419,“custom_type”:"",“channel”:{“channel_unread_message_count”:1,“custom_type”:"",“name”:“Team”,“channel_url”:“sendbird_group_channel_},“created_at”:1647946275881,“message_id”:6783796711,“message”:” How are you?", “type”:“MESG”,“unread_message_count”:1,“push_title”:“New Message”,“audience_type”:“only”,“sender”:{“require_auth_for_profile_image”:false,“profile_url”:"",“name”:“abc”,“id”:“69”},“push_sound”:“default”,“translations”:{},“recipient”:{“name”:“xyz”,“push_template”:“default”,“id”:“266”},“files”:[],“category”:“messaging:offline_notification”,“channel_type”:“group_messaging”,“mentioned_users”:[],“app_id”:"*********"} */

        if (remoteMessage.getData().containsKey("message"))
            messageText = remoteMessage.getData().get("message");
/* messageText = "You have a message from your Team." and Looking for this massage in transalated format.*/

        if(remoteMessage.getData().containsKey("translations")) {
            messageText = remoteMessage.getData().get("translations");
            Log.d("Sendbird push notification transalated",":"+messageText);
        }

    }
}

Hi @Smita ,

I couldn’t find anything suspicious on your code except the List interface in order to set the language preference. You should create the List of String like below.

List<String> preferredLanguages = new ArrayList<>();

I’ve tested the translation based on your code and could get the translated message(“es”) through the Push Notification successfully.

NOTE: You can validate whether the user’s preferred_languages is set properly or not via the following API.

image