-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix(messaging): RemoteMessage.data may be JSON-serializable object as well as string #7316
fix(messaging): RemoteMessage.data may be JSON-serializable object as well as string #7316
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct, thank you for posting this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that's why we have tests 😆 thank you for adding the test change so it was covered or we may not have seen this
1) remoteMessage modular
firebase v8 compatibility
messaging().sendMessage(*)
data
accepts custom data value:
NativeFirebaseError: [messaging/unknown] Value for fooObject cannot be cast from ReadableNativeMap to String
at FirebaseMessagingModule.sendMessage (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.invertase.testing&modulesOnly=false&runModule=true&sourceMapURL=true:25[2691](https://github.com/invertase/react-native-firebase/actions/runs/6016676986/job/16457624689?pr=7316#step:19:2695):28)
at Context.<anonymous> (/Users/runner/work/react-native-firebase/react-native-firebase/packages/messaging/e2e/remoteMessage.e2e.js:182:40)
Interesting - so, is it possible for it to truly be type Because the Java API for RemoteMessage.addData only accepts string/string parameters, implying that objects were not really contemplated as parameters: https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/RemoteMessage.Builder#addData(java.lang.String,java.lang.String) It's possible we can serialize the object to JSON prior to sending it down to native, and I think that's likely the best course - in lib/index.js checking if it is typof string (or similar?) and if it is not then doing a What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
underlying API is string/string, so object must be serialized I think, which is easiest at javascript layer prior to sending it to native layer
@mikehardy I'm working on the solution you suggested, finishing up tests and validations to give me some confidence it's gonna work correctly. I do want to provide some info and to make sure that this PR suggestion is valid. We are using the Firebase console to send notifications and the following is what we are receiving .
So, we only see the type issue on the iOS notifications and we only see this issue when using the Firebase console to send notifications. Went through some sanity checks including looking at our Notifications Service to make sure we weren't modifying the notifications...and I don't see anything. Just wanted to give an update and the additional info in case it might be helpful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a subtle one but a valid one - I think this matches up with underlying SDK params now as well as actual experience of getting objects in RemoteMessage 🤞
Description
Discovered through testing that the type for data on the RemoteMessage could be a string or an object. This was
Related issues
Fixes #7279
Release Summary
Checklist
Android
iOS
e2e
tests added or updated inpackages/\*\*/e2e
jest
tests added or updated inpackages/\*\*/__tests__
Test Plan
Updated e2e test to include an object and string to reflect updated types option.
Think
react-native-firebase
is great? Please consider supporting the project with any of the below:React Native Firebase
andInvertase
on Twitter🔥