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

Remote notifications message is null when payload uses body_loc_key in foreground #1836

Closed
plus- opened this issue Jan 20, 2021 · 7 comments
Closed

Comments

@plus-
Copy link
Contributor

plus- commented Jan 20, 2021

Bug

This is a bug on Android.

I have an issue when trying to internationalize my notifications messages using the body_loc_key parameter See table 2.b

When the app is in foreground the notification message property is null. In background the notification will display properly and show the value of the resources string.

Using the body parameter will properly work in background and foreground (message is the body value)

Environment info

"react-native-push-notification": "^7.0.0",

react-native info output:

info Fetching system and libraries information...
(node:22905) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
System:
    OS: macOS 11.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 462.41 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.15.1 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.0 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3
      System Images: android-R | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6953283
    Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_222 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found```
@Dallas62
Copy link
Collaborator

Dallas62 commented Jan 20, 2021

Hi @plus-
Unfortunately, this repository is not for iOS.

Please refer to:
https://github.com/react-native-push-notification-ios/push-notification-ios

Also note that the iOS library doesn't use Firebase.

Regards,

@plus-
Copy link
Contributor Author

plus- commented Jan 20, 2021

@Dallas62 this is an issue with Android. I have no problem with IOS. See table 2.b is for Android

@Dallas62 Dallas62 reopened this Jan 20, 2021
@plus-
Copy link
Contributor Author

plus- commented Jan 20, 2021

thanks for reopening this issue, I believe this could be extended with

https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/RemoteMessage.Notification#getBodyLocalizationKey()

If this is not a priority for you to add I can understand. Let me know.

@Dallas62
Copy link
Collaborator

The issue is coming from:
https://github.com/zo0r/react-native-push-notification/blob/master/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java#L50

Which is using the getBody and doesn't provide a fallback to the localisation key. I don't know why Firebase makes us reinvent the wheel each time the application is open...

getTitle is also impacted.

https://stackoverflow.com/questions/7493287/android-how-do-i-get-string-from-resources-using-its-name
The second answer should work in our case.

I will try to look at it this week-end, if you have time, feel free to make a PR 😉

Regards,

@plus-
Copy link
Contributor Author

plus- commented Jan 20, 2021

I did a PR, I don't have a Java environment right now, so I couldn't test it.

@Dallas62
Copy link
Collaborator

Thanks for the PR,

If you have your project, you can apply your change directly in the node_modules, it's not perfect but it's help to test 😉

I will look this weekend and release it ASAP.

@Dallas62
Copy link
Collaborator

Hi @plus-
Your patch has been tested and released 😉 (#1837)
Thanks for your report and contribution !
Regards

@Dallas62 Dallas62 unpinned this issue Feb 4, 2021
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