Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Android Push Notification localization #771

Closed
fordkilleen opened this issue Oct 17, 2022 · 1 comment
Closed

Add support for Android Push Notification localization #771

fordkilleen opened this issue Oct 17, 2022 · 1 comment

Comments

@fordkilleen
Copy link

fordkilleen commented Oct 17, 2022

Howdy!

Missing Feature / Bug

I recently found an issue where our push notifications were no longer coming through in the foreground even while still using the notification_foreground data value. It turned out that this behavior started when we began using localization in our push notifications instead of providing fixed strings from the backend. The push notifications had the correct content when the app was not in the foreground, but would not appear at all when in the foreground. Looking deeper into this code I realized that it was not checking for the localization keys. Therefore, since we were not providing a title and body, but instead a title_loc_key and body_loc_key, the foreground logic was deciding not to show the foreground notification. See the links below for Firebase documentation and examples.

Feature request

I am requesting the localization fields be supported so that our notifications are consistent and displayed the same whether we are in the foreground or not. This will be beneficial for anyone who is using the localization to support multiple languages on the client side and also want to have working foreground notifications.

Missing keys from the foreground notification check:

  • title_loc_key
  • title_loc_args
  • body_loc_key
  • body_loc_args

Solution

I have just implemented a small fix for this on my own fork of this repo and it looks like it is working perfectly. Supporting messages with and without arguments. The logic is, if the localized versions of the title and body exist, use them instead, otherwise continue on as per normal. I will raise a PR shortly and link it here also.
PR #772 has now been raised.

Links

Android Notification object documentation
Cloud Messages with localization example

@dpa99c
Copy link
Owner

dpa99c commented Nov 23, 2022

PR has been merged into [email protected] which has just been released to npm

@dpa99c dpa99c closed this as completed Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants