Improve report comment push notification background updates
See original GitHub issueBoth iOS and Android impose limitations on how frequently push notifications can wake the app from the background, and on how long those apps can remain awake in the background. Some variables that help determine whether this happens are:
- How much battery life the device has
- Whether the device is on low-power mode
- The availability of cellular data
- How frequently the user uses the app
iOS is far more strict, warning that developers “shouldn’t count on more than 2-3 background updates per hour”. While we likely can’t do anything to circumvent these OS limitations, we can make the most of the background time we’re given.
Action Performed:
With the app backgrounded or closed, receive a report comment push notification that wakes the app for a background update.
Expected Result:
- Look at the sequence number of the
ReportActionincluded in the payload of the push notification. - If it is equal to the highest sequence number we had previously in Onyx plus one, just add the single report action to Onyx.
- Otherwise, fetch all the report actions between the highest sequence number we had previously in Onyx and the one included in the payload of the push notification. Thus ensuring that any messages we missed on that report will be added to Onyx.
Alternate Solution
Always fetch the report actions for the given report. Use pagination and fetch the newest ones first, until we receive a response that contains a report action with the highest sequence number we previously had in Onyx. This might be simpler, but also might be “riskier”, because I’m not sure that the OS will want to let you make network requests when woken from the background. So we might only want to fall back on that behavior if necessary.
Actual Result:
The one ReportAction included in the payload of the push notification is added to the report in Onyx.
Workaround:
n/a
Platform:
iOS Android
Version Number: 1.0.77-2
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (10 by maintainers)

Top Related StackOverflow Question
I like doing them both – push notifications will be fast but unreliable, and background polling will be reliable but slow. This combined with doing an update on open should provide the best possible experience.
On Mon, Jul 26, 2021 at 2:29 PM Rory Abraham @.***> wrote:
Yeah, I think this should be in addition to the notification background updates (but we probably wouldn’t need to implement the expected result listed in this issue description).
Nope, what I meant to say is that if we use periodic checks instead of making additional API calls in a background service, then I think the OS would throttle our notifications less often. This remains to be seen though.
Sure, here. Here is the change introduced in Android 12, which mentions that if less than 10 seconds, the notification won’t be displayed.
It’s worth mentioning that this is not just any notification, but a special notification that is tied to the background service. According to this blog post, not all of the React Native libraries support this, so we’ll need to check carefully if we believe that following these rules will lead to less throttling of notifications.
Finally, here is the main point. This limitation will apply once we target Android 12 (we will be forced to within 12 months):
The special cases that we will depend on are: