设备离线时接收所有推送通知 [英] Receive all the push notifications when devices are offline

查看:137
本文介绍了设备离线时接收所有推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个iOS和Android本机应用程序,使用Firebase发送推送通知.

I'm creating an iOS and Android native app, using Firebase for sending push notifications.

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

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.

即使设备处于脱机状态且已启动,有没有办法接收所有推送通知?

Is there a way to receive all the push notifications even when the devices are offline and they're started?

推荐答案

引用了两个引用:

iOS:

Apple Push Notification服务包括服务质量(QoS) 执行存储转发功能的组件.如果APNs尝试 发送通知且目标设备处于脱机状态,APN 将通知存储一段有限的时间并将其传递 当设备再次变得可用时.该组件仅存储 每个设备和每个应用程序的最新通知.如果设备是 离线,发送针对该设备的通知请求导致 先前的请求将被丢弃.如果设备保持离线状态 很长一段时间,它在APN中存储的所有通知都将被丢弃.

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.

  • 该组件仅存储每个设备和每个应用程序的最新通知.
  • 如果设备离线,则发送针对该设备的通知请求会导致先前的请求被丢弃.
    • 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:

      在Android和Web/JavaScript上,您可以指定最大使用寿命 一个消息.该值必须是0到2,419,200秒之间的持续时间 (28天),它对应于 FCM存储并尝试传递消息.没有的要求 包含此字段的默认期限为最长四个星期.

      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.

      当前,iOS上的通知消息不支持time_to_live

      Currently, time_to_live is not supported for notification messages on iOS

      如果设备未连接到GCM,则消息将被存储 直到建立连接为止(再次遵守折叠键) 规则).建立连接后,GCM会发送所有待处理的邮件 消息到设备.如果设备再也无法连接(对于 例如,如果它已恢复出厂设置),则该消息最终将计时 并从GCM存储中丢弃.默认超时为4周, 除非设置了time_to_live标志.

      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.

      最后,当GCM尝试将消息传递到设备时, 应用程序已卸载,GCM会立即丢弃该消息 并使注册令牌无效.将来尝试发送 消息发送到该设备将导致NotRegistered错误.

      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会立即丢弃该消息并使注册令牌无效.
        • 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.
        • 意味着它应该正在接收挂起的消息.除非设备已恢复出厂设置或已卸载.

          Meaning it should be receiving the pending messages. Unless the device is factory reset or uninstalled.

          关于FCM消息

          消息传递的概念和选项(尽管已弃用,现在建议参考FCM消息,在上方链接)

          Messaging Concepts and Options (although this is deprecated and now suggests to reference FCM messaging, linked above)

          这篇关于设备离线时接收所有推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆