当我向离线(例如,处于飞行模式或关闭)的 iOS 设备发送通知时,我无法弄清楚 FCM 的行为方式。
关于 time_to_live
的文档属性提到 Currently, time_to_live is not supported for notification messages on iOS.
但没有提供对所做操作的解释。我试过测试它,似乎推送通知有时会通过,有时不会,无论我将 time_to_live
属性设置为什么,尽管我不确定这是否到期节流或 FCM 端发生的其他事情。
相关地,我似乎无法让 delay_while_idle
属性在 iOS 上工作,尽管文档没有明确提到它不适用于 iOS - 通知是在手机上发送的即使我将 delay_while_idle
设置为 true,睡着了仍然会唤醒手机。
有人知道这是如何工作的吗?
最佳答案
time_to_live
是适用于 Android 和 iOS 的 AFAIK。但是,由于 FCM 向 iOS 设备发送消息的过程是这样的:
App Server > FCM Server > APNs > iOS device
可以肯定地说,只有 FCM 服务器使用 time_to_live
,因为它是 description :
This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks. For more information, see Setting the lifespan of a message.
环顾四周,发送到离线设备时 APN 的行为是(来自 Apple docs ):
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.
截至目前,delay_while_idle
现已弃用。
据我所知,唤醒 iOS 手机(在线/连接到正常网络)的方法很简单,就是 set the priority
to high
.
https://stackoverflow.com/questions/38273509/