Cenobyte321
Cenobyte321

Reputation: 479

Abnormal behaviour with push notifications in iOS after device goes online

I'm using Parse for push notifications within an Ionic application. Although push notifications work correctly in both iOS and Android when the device is online, when the device goes offline and then online the behaviour in Android and iOS differ significantly.

In Android all notifications sent while the device was offline are received. In iOS either one of the following happens:

Is this seemingly random behaviour expected in APNS or is there some setting I'm missing from Parse? I have read also that APNS should not be relied upon for this kind of situation.

Upvotes: 2

Views: 206

Answers (1)

Baris Akar
Baris Akar

Reputation: 4965

From the official APNS documentation:

Apple Push Notification service includes a Quality of Service (QoS) component that performs a store-and-forward function.

If APNs attempts to deliver a notification and the destination device is offline, APNs stores the notification for a limited period of time and delivers it when the device becomes available again.

This component stores only the most recent notification per device and per app. If a device is offline, sending a notification request targeting that device causes the previous request to be discarded. If a device remains offline for a long time, all its stored notifications in APNs are discarded.

Apple Push Notification service includes a Quality of Service (QoS) component that performs a store-and-forward function. If APNs attempts to deliver a notification and the destination device is offline, APNs stores the notification for a limited period of time and delivers it when the device becomes available again. This component stores only the most recent notification per device and per app. If a device is offline, sending a notification request targeting that device causes the previous request to be discarded. If a device remains offline for a long time, all its stored notifications in APNs are discarded.

For GCM you can achieve a similar behaviour using collapse keys:

This parameter identifies a group of messages (e.g., with collapse_key: "Updates Available") that can be collapsed, so that only the last message gets sent when delivery can be resumed. This is intended to avoid sending too many of the same messages when the device comes back online or becomes active (see delay_while_idle).

Note that there is no guarantee of the order in which messages get sent.

The random behaviour on iOS seems weird, but maybe it's just because push notifications are not 100% guaranteed to be delivered, and also not in the order they were sent.

Upvotes: 2

Related Questions