我在 Ionic 应用程序中使用 Parse 推送通知。虽然当设备在线时推送通知在 iOS 和 Android 中都能正常工作,但当设备离线然后在线时,Android 和 iOS 中的行为有很大不同。
在 Android 中,设备离线时发送的所有通知都会被接收。在 iOS 中,会发生以下任一情况:
- 我收到所有推送通知
- 我没有收到推送通知
- 我从队列中随机收到一条推送通知
- 我收到队列中的最后一条通知
这种看似随机的行为是在 APNS 中预期的,还是我在 Parse 中遗漏了一些设置?我还读到这种情况不应依赖 APNS。
Best Answer-推荐答案 strong>
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% 保证送达,也不是按照它们发送的顺序。
关于ios - 设备上线后 iOS 推送通知出现异常行为,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/31545342/
|