-
-
Notifications
You must be signed in to change notification settings - Fork 102
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: FCM push notification payload incompatible with Parse Android SDK #238
Conversation
Thanks for opening this pull request!
|
@jimnor0xF I have intentionally left the tests to fail so that we can discuss what is right and what is wrong. |
@mman I guess rawPayload does not work with the Android SDK either, unless a user put those keys in themselves. Not sure if we want/need to support that out of the box. |
@mtrezza Should rawPayload be supported out of the box for the Parse Android SDK? In that case we basically need to add those time/push_id keys if "android" is present in the payload as well. Personally, I don't see the need, since I'd prefer it to not be dependent on some client side implementation. |
@mman What do you think? Not sure I fully understand what the issue is, could someone explain again, please? I'd just keep in mind that developers cannot easily change the (custom) push adapter implementation in all their rolled out apps, so whatever we can do here to make life easier for developers will likely be appreciated. |
@mtrezza @jimnor0xF I will try to explain what I have learned over the years:
Now point 3. is what @jimnor0xF calls But because of 4. we have our own iOS and Android payload API that gets passed to More over, Parse Server + Parse Push Adapter agreed with Parse Android SDK in the past that each Android push will have For now, I see one remaining problem: Parse Server Push Adapter, should probably still support expected One issue I identified is that in the past we supported Second issue is that when you send to Android we misplace the More issues perhaps may pop up as more people migrate to push adapter 6.x. I will update this PR and will test it more, and try to at least open issues against thing that no longer work - but that have a reasonable workaround - so that we can mention them in README. |
Thanks for the explanation. What is the suggested solution, with the least impact for developers? Mind that we have only 4 weeks left until Google will decommission the legacy API. Let's assume the viewpoint of a developer for an app that currently sends pushes to Apple (directly to APNS via
So we'd need to transform the payload that is sent to the Parse Android SDK push module so that it works properly. For apps that subclassed the Does that make sense and is that technically possibly? Or does the new FCM API send a payload to the device that we cannot fully influence and therefore the Parse Android SDK cannot interpret the push correctly? That would be the worst case scenario. For example @mman wrote:
If we change this structure, will the Parse Android SDK still interpret that correctly? What about apps that extend the |
@mtrezza You summarized it nicely. My expectation is to simply add I think it is technically possible and I will try to work on it next Monday. The issues I identified are:
once these three are addressed it should work. I assume everybody affected will start migrating over the next few weeks so cutting 6.0.1 before the end of next week should work. |
It would be amazing if we could get this done by next week. I believe this is an all-hands on deck issue, but few people are actually aware of this challenge. Once we have a release next week, we'll post this on our social media to invite more developers to test this out. Thanks @jimnor0xF and @mman for your efforts so far! |
@mman @jimnor0xF So this one should be ready to go, I have verified that it works with my apps with no changes required other than adding the |
@mman Great - I understand you tested this out with Android and Apple push notifications on real devices? |
I tested on real Android devices, where push for Android goes via |
@jimnor0xF Could you review as well before we merge? |
Hello guys, I raised this PR #246 with the compatibility for nested objects. Could you please leave your comments? |
So I'll wait with merging until we have figured out what #246 contains in the context of this PR - does it contain subset of this PR, or is it an amendment,...? |
I'm honestly not sure, since I started using push on Apple first and then added Android devices, I was only able to uncover the missing nested So I need @charles-ramos to answer whether he intents to support new functionality, or whether migration to latest FCM broke something for him... |
The idea is to keep everything compatible with the current code (GCM) that uses "data" for sending push notifications for Android. Right now, in case I want to send push notifications to everyone (android and iOS), I must use both "data" and "notification". With the PR I raised, it will be possible to keep using "data" for both. |
During my tests using the changes mentioned in this branch, I got some results here: First of all, I tested this code for sending push notifications:
I got the following error:
Due to this line: parse-server-push-adapter/src/FCM.js Line 265 in 8b93e22
After adding a console.log() to see what was my androidPayload, I got this:
Then, I removed and tested it, but I did not receive the notification for Android (only for iOS, with the content from the If I tried sending a push notification without
Which seems to be expected. Testing via Dashboard, I did not receive any notifications for android, as the dashboard only sends push notifications through Is there anything that I'm not concerned about? As a reference, I used the code described in the documentation: https://docs.parseplatform.org/js/guide/#sending-pushes And used the push options listed here: https://docs.parseplatform.org/js/guide/#sending-options |
I'd like to chime in and share details about our current structure for sending push notifications. Here’s how we format our payload with a nested data object:
After updating to
This error only shows when we send pushes manually through the server console. However, when our system sends pushes, they seem to fail silently without any error messages appearing in the logs. |
@mman @astroblemeal |
Strange, looks like the JSON body in your example is missing a comma though. Not sure if that has anything to do with it. Did that payload work before with the legacy FCM (GCM.js)? Can you try with this payload?
Could you share some info about what you are running on your Android device? Are you using the Parse Android SDK to handle pushes? On the topic of using the I have to use the And like your PR mentioned #246, you have to specify But this was the case in the past as well. At least in my experience with a customised setup, and according to the code in GCM.js which does not merge the So I do not think we are dependent on #246 to fix some backwards incompatibility issue. Please correct me if I'm wrong though. For people that intend to use the Firebase Cloud Messaging SDK on the client side to handle pushes or that are using a customised setup, you are better off using the |
So I'll go ahead and merge this PR and then @charles-ramos can rebase his PR on the latest commit. This may make it easier to test everything out. Please feel free to continue the discussion here, despite the PR being merged. |
## [6.1.1](6.1.0...6.1.1) (2024-05-15) ### Bug Fixes * FCM push notification payload incompatible with Parse Android SDK ([#238](#238)) ([4274b7f](4274b7f))
🎉 This change has been released in version 6.1.1 |
After merging this PR there is a conflict in #246 (comment); if @charles-ramos could resolve this, then we can get a clearer picture of what that PR adds after this PR. |
@jimnor0xF It works keeping the same payload structure with the nested data object, and setup as before using Any idea when these changes will be released in |
@mtrezza Looks like parse server itself is has hard pinned the dependency on push adapter |
It's actually much simpler. See Installation, Configure and Bundled with Parse Server. I rewrote the README yesterday to explain this. But we should make a Parse Server release with the new adapter as well before June. |
hmm, not fully getting it at first glance. I got around it by also adding
|
|
New Pull Request Checklist
Issue Description
Closes: #237
Sending push notifications to Android phones does not work anymore because data are converted and sent out differently using
FCM.js
than they were using theGCM.js
.This means that Parse Android SDK is unable to parse the message correctly, and deliver it to user specified broadcast receiver, silently dropping any received messages.
Approach
Parse.Push.send
was initially built around support for iOS, and later added support for Android, and Android SDK.Parse.Push.send
accepts a dictionary that we callrequestData
.Historically sending push notifications to Apple meant passing in an
alert: "Push Notification"
key inrequestData
. Later when Apple added support for push notification titles and subtitles, push adapter offered two ways how to specifytitle
andsubtitle
. Either in top levelrequestData
, like this:or via nested
alert
dictionary inside ofrequestData
like this:In both of these cases, such
requestData
would end up being converted to the payload accepted by the APNS always getting the second form with nestedalert
dictionary.The Android side of things did not do any special formatting of user data, and would simply use whatever data user passed into
requestData
and just JSON encode them into string. For client side processing, Android SDK requires to specifypushId
andtime
. The final Android payload then looked like this:This PR adjusts the code to provide support for consuming nested
alert
dictionary as before, and it modifies the Android path to properly encode data into JSON string and decorate the payload correctly withpush_id
andtime
to receive notifications on devices currently in circulation with existing versions of Parse Android SDK.TODOs before merging