设备上线后 iOS 中推送通知的异常行为
Abnormal behaviour with push notifications in iOS after device goes online
我在 Ionic 应用程序中使用 Parse 推送通知。虽然当设备在线时推送通知在 iOS 和 Android 中都能正常工作,但当设备离线然后在线时,Android 和 iOS 中的行为有很大不同。
在 Android 中,接收设备离线时发送的所有通知。在 iOS 中会发生以下任一情况:
- 我收到所有推送通知
- 我没有收到推送通知
- 我从队列中随机收到一个推送通知
- 我收到队列中的最后一条通知
这种看似随机的行为是在 APNS 中预期的,还是我在 Parse 中缺少某些设置?我还读到,在这种情况下不应依赖 APNS。
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.
对于 GCM,您可以使用 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.
iOS 上的随机行为看起来很奇怪,但这可能只是因为推送通知不能 100% 保证送达,而且也不是按照它们发送的顺序。
我在 Ionic 应用程序中使用 Parse 推送通知。虽然当设备在线时推送通知在 iOS 和 Android 中都能正常工作,但当设备离线然后在线时,Android 和 iOS 中的行为有很大不同。
在 Android 中,接收设备离线时发送的所有通知。在 iOS 中会发生以下任一情况:
- 我收到所有推送通知
- 我没有收到推送通知
- 我从队列中随机收到一个推送通知
- 我收到队列中的最后一条通知
这种看似随机的行为是在 APNS 中预期的,还是我在 Parse 中缺少某些设置?我还读到,在这种情况下不应依赖 APNS。
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.
对于 GCM,您可以使用 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.
iOS 上的随机行为看起来很奇怪,但这可能只是因为推送通知不能 100% 保证送达,而且也不是按照它们发送的顺序。