gpt4 book ai didi

ios - 设备上线后 iOS 中推送通知的异常行为

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:58:48 24 4
gpt4 key购买 nike

我在 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% 保证送达,而且也不是按照它们发送的顺序。

关于ios - 设备上线后 iOS 中推送通知的异常行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31545342/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com