gpt4 book ai didi

android - 设备离线时接收所有推送通知

转载 作者:行者123 更新时间:2023-12-02 04:07:51 25 4
gpt4 key购买 nike

我正在创建一个 iOS 和 Android native 应用,使用 Firebase 发送推送通知。

它工作正常,但是当我关闭设备并发送一些通知时,启动设备后,我只收到 iOS 发送的最后一个通知,Android 也是如此。

有没有办法即使在设备离线且启动时也能接收所有推送通知?

最佳答案

引用一些引用文献:

iOS:

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.

  • 此组件仅存储每个设备和每个应用的最新通知。
  • 如果设备处于离线状态,发送针对该设备的通知请求会导致之前的请求被丢弃。

这意味着仅保留一个通知,并且发送新通知会替换旧通知。所以我认为这是不可能的。

Local and Remote Notification Programming Guide

安卓:

On Android and Web/JavaScript, you can specify the maximum lifespan of a message. The value must be a duration from 0 to 2,419,200 seconds (28 days), and it corresponds to the maximum period of time for which FCM stores and attempts to deliver the message. Requests that don't contain this field default to the maximum period of four weeks.

Currently, time_to_live is not supported for notification messages on iOS

If the device is not connected to GCM, the message will be stored until a connection is established (again respecting the collapse key rules). When a connection is established, GCM delivers all pending messages to the device. If the device never gets connected again (for instance, if it was factory reset), the message will eventually time out and be discarded from GCM storage. The default timeout is 4 weeks, unless the time_to_live flag is set.

Finally, when GCM attempts to deliver a message to the device and the application was uninstalled, GCM will discard that message right away and invalidate the registration token. Future attempts to send a message to that device will result in a NotRegistered error.

  • 建立连接后,GCM 会将所有待处理消息传送到设备。
  • 如果设备再也无法连接(例如,恢复出厂设置),该消息最终将超时并从 GCM 存储中丢弃。
  • 默认超时为 4 周,除非设置了 time_to_live 标志。
  • 最后,当 GCM 尝试向设备发送消息并且应用程序被卸载时,GCM 将立即丢弃该消息并使注册 token 失效。

这意味着它应该接收待处理的消息。除非设备恢复出厂设置或卸载。

About FCM Messages

Messaging Concepts and Options (尽管这已被弃用,现在建议引用上面链接的 FCM 消息传递)

关于android - 设备离线时接收所有推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52522362/

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