-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[$250] Support compressed push notification payloads #54820
Comments
Triggered auto assignment to @jliexpensify ( |
Adam from Callstack, I'd like to work on this. |
Job added to Upwork: https://www.upwork.com/jobs/~021876663566682945155 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @dominictb ( |
Hi @adhorodyski, how's the progress so far? |
Hey, sorry for missing an update in here! I took the time to look around for solutions available, here's what I have so far: Steps required for processing on each platform:
Now the gzip decompression step is not so straightforward in Hermes (JS) because we're missing native utilities to do so. CompressionStream is only discussed so far as a non-ECMAScript feature to be added. I also started with the JS implementation working on this branch: https://github.com/callstack-internal/Expensify-App/tree/feat/compressed-push-notifications (here's the current diff) |
@arosiclair actually before I proceed further, I'd like to ask one crucial question:
Is it possible that we take an alternative approach and only send down what the client needs to fetch itself from the API? Have this been considered before? |
Yeah we handle on this on the backend. You can expect payload data in every push notification. The
We are doing this already actually. The payload will contain some onyx updates and the client will attempt to merge them. If it detects that there are other missed onyx updates, those will be fetched from the API using |
Oh sorry if I phrased this poorly - I was thinking "can we send as little as possible in the notification" so that we don't actually have to try walk around the limit? Offloading this from the notification to the device can not only simplify it, but also save us the trouble in the future. I'm worried we'll eventually hit the wall even with gzipped content and will be back at square 1. |
I see what you mean. For context, our philosophy has been to use push notifications as another channel for Onyx data delivery. Push notifications are special since they can push updates to the app even when it isn't running and even when the connection is slow/unreliable. So we try to leverage that to keep the client as up to date as possible. For now, we shouldn't worry too much about further payload size increases down the line. We have lots of integration tests to make sure that doesn't happen (at least not by accident). If it does become an issue again, we'll just start another discussion on how to move forward. This issue was born from one of those discussions for example. |
Oki, that makes sense now! Just a heads up we might be able to leverage https://github.com/Expensify/App/tree/main/modules/background-task just for that if we decide it's not enough, cc @szymonrybczak who authored it. It was designed to use best available APIs on each platform to handle background jobs, but I know iOS has some design limitations when we close the app completely. I now know fully what we're dealing with, thanks @arosiclair. I will continue with Android now on the linked branch and add unit tests on the JS for the parsing. |
Update: I pushed Android's implementation today, will test this tomorrow together with web. |
I was able to verify today that Android passes fine, working on the iOS implementation now. Discussed with @staszekscp that for Hybrid we'd need to:
|
Update: I think I've completed the iOS version, will see how we can go about testing this one as well as plug it in into Hybrid. |
Hey! As I'll be off next week for the onshore event @VickyStash will take over this issue to finish up the Hybrid integration. |
Feel free to comment @VickyStash and I'll assign you |
Hi, I'm Viktoryia from Callstack - expert contributor group - and I would like to work on this issue. |
📣 @dominictb 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
Assigned you @VickyStash |
Updates:
TODOs:
|
Updates: If there are no more unexpected crashes/issues - the PRs should be ready for review on Tue/Wed. |
Oh yeah FYI, we're working on fixing that here |
Updates
TODOs: |
That's fine no need for that now 👍 |
Updates: |
Background
We include Onyx data in the payload for each of our push notifications. On receipt, we merge the onyx data and update the app with any previously missed onyx updates if necessary (src). However, there is a 4 KB size limit for push notification payloads, so we remove the Onyx data when see the payload would be too large. This usually happens because the message for the push notification is too long. Additionally, we're implementing some optimizations in the backend where we squash multiple Onyx updates together to reduce the number updates we store in the database which also increases the potential payload size.
Problem
The 4KB size limit prevents Onyx data delivery in push notifications for large messages and prevents us from squashing onyx updates in some scenarios.
Solution
Support push notification payloads that are compressed using GZIP so that we can fit more data. Specifically, the value in
payload
would be a GZIP compressed JSON string. Decompressing and parsing the string as an object should yield the same payload object that we normally receive now.To ensure backward compatibility we should still support uncompressed payloads. We'll start sending compressed push notification payloads when we're confident clients have broad support for it.
We'll need to support compressed payloads in both JS and native code:
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @adhorodyskiThe text was updated successfully, but these errors were encountered: