firebase / firebase/firebase-android-sdk

"title" and "body" get priority over "titleLocKey" and "bodyLocKey"

Open
#3,938 10 comments 7 reactions 0 assignees View on GitHub
api: messaging type: feature request
Dominant language
Java
Stars
2.6k
Forks
710
Avg merge
2d 9h
Merged PRs (30d)
31

Description

Initially created the issue in the [flutterfire](https://github.com/firebase/flutterfire/issues/9207) repo.

### [REQUIRED] Step 3: Describe the problem

#### Steps to reproduce:

When sending a notification with both `title` and `titleLocKey`, the app would prioritise `title` over `titleLocKey` when displaying the notification. I would expect that if a translation is found, then it should be used. Otherwise (maybe the user hasn't updated the app), then it should default to the `title`.

#### Relevant Code:

I think the relevant code is [here](https://github.com/firebase/firebase-android-sdk/blob/7c277af0c1fca04b26c7c40f641b07541c04f612/firebase-messaging/src/main/java/com/google/firebase/messaging/NotificationParams.java#L377). We should be swapping getString and getLocalizedString like so:

```java
public String getPossiblyLocalizedString(Resources resources, String packageName, String key) {
String localized = getLocalizedString(resources, packageName, key);
if (!TextUtils.isEmpty(localized)) {
return localized;
}

return getString(key);
}
```

Or is it the expected behaviour?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.