• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

[复制链接]
菜鸟教程小白 发表于 2022-12-12 15:52:31 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我在 Ionic 应用程序中使用 Parse 推送通知。虽然当设备在线时推送通知在 iOS 和 Android 中都能正常工作,但当设备离线然后在线时,Android 和 iOS 中的行为有很大不同。

在 Android 中,设备离线时发送的所有通知都会被接收。在 iOS 中,会发生以下任一情况:

  • 我收到所有推送通知
  • 我没有收到推送通知
  • 我从队列中随机收到一条推送通知
  • 我收到队列中的最后一条通知

这种看似随机的行为是在 APNS 中预期的,还是我在 Parse 中遗漏了一些设置?我还读到这种情况不应依赖 APNS。



Best Answer-推荐答案


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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap