iOS 离线时的 FCM 行为

FCM behavior when offline for iOS

当我向 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 - 在 phone 睡眠时发送的通知仍然会唤醒 phone,即使我将 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 phone(online/connected 一个体面的网络)的方法是只是 set the priority to high.