简体   繁体   English

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

[英]Receive all the push notifications when devices are offline

I'm creating an iOS and Android native app, using Firebase for sending push notifications.我正在创建一个 iOS 和 Android 本机应用程序,使用 Firebase 发送推送通知。

It's working fine, but when I switch off my devices and send some notifications, after starting the devices, I just receive the last one sent for iOS, and the same for Android.它工作正常,但是当我关闭设备并发送一些通知时,在启动设备后,我只收到为 iOS 发送的最后一个通知,对于 Android 也是如此。

Is there a way to receive all the push notifications even when the devices are offline and they're started?有没有办法在设备离线并启动时接收所有推送通知?

Referencing a couple of references:参考几个参考:

iOS: IOS:

Apple Push Notification service includes a Quality of Service (QoS) component that performs a store-and-forward function. Apple 推送通知服务包括一个执行存储和转发功能的服务质量 (QoS) 组件。 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.如果 APNs 尝试传递通知并且目标设备处于离线状态,APNs 会将通知存储一段有限的时间,并在设备再次可用时传递它。 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.如果设备长时间处于离线状态,则其在 APN 中存储的所有通知都将被丢弃。

  • 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.如果设备处于离线状态,发送针对该设备的通知请求会导致之前的请求被丢弃。

This would mean that only one notification is preserved and that sending a new one replaced the old one.这意味着只保留一个通知,并且发送一个新通知取代了旧通知。 So I don't think it's possible.所以我认为这是不可能的。

Local and Remote Notification Programming Guide 本地和远程通知编程指南

Android:安卓:

On Android and Web/JavaScript, you can specify the maximum lifespan of a message.在 Android 和 Web/JavaScript 上,您可以指定消息的最长生命周期。 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.该值必须是从 0 到 2,419,200 秒(28 天)的持续时间,它对应于 FCM 存储和尝试传递消息的最长时间。 Requests that don't contain this field default to the maximum period of four weeks.不包含此字段的请求默认最长期限为 4 周。

and

Currently, time_to_live is not supported for notification messages on iOS目前,iOS 上的通知消息不支持 time_to_live

and

If the device is not connected to GCM, the message will be stored until a connection is established (again respecting the collapse key rules).如果设备未连接到 GCM,则消息将被存储,直到建立连接(再次遵守折叠密钥规则)。 When a connection is established, GCM delivers all pending messages to the device.建立连接后,GCM 会将所有待处理消息传送到设备。 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.如果设备不再连接(例如,如果它被恢复出厂设置),消息最终会超时并从 GCM 存储中丢弃。 The default timeout is 4 weeks, unless the time_to_live flag is set.默认超时为 4 周,除非设置了 time_to_live 标志。

and

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.最后,当 GCM 尝试向设备发送消息并且应用程序被卸载时,GCM 将立即丢弃该消息并使注册令牌无效。 Future attempts to send a message to that device will result in a NotRegistered error.以后尝试向该设备发送消息将导致 NotRegistered 错误。

  • When a connection is established, GCM delivers all pending messages to the device.建立连接后,GCM 会将所有待处理消息传送到设备。
  • 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.如果设备不再连接(例如,如果它被恢复出厂设置),消息最终会超时并从 GCM 存储中丢弃。
  • The default timeout is 4 weeks, unless the time_to_live flag is set.默认超时为 4 周,除非设置了 time_to_live 标志。
  • 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.最后,当 GCM 尝试向设备发送消息并且应用程序被卸载时,GCM 将立即丢弃该消息并使注册令牌无效。

Meaning it should be receiving the pending messages.这意味着它应该接收待处理的消息。 Unless the device is factory reset or uninstalled.除非设备恢复出厂设置或卸载。

About FCM Messages 关于 FCM 消息

Messaging Concepts and Options (although this is deprecated and now suggests to reference FCM messaging, linked above) 消息概念和选项(虽然这已被弃用,现在建议参考上面链接的 FCM 消息)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM