本文介绍了iOS 离线时的 FCM 行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我向离线(例如处于飞行模式或关机状态)的 iOS 设备发送通知时,我无法弄清楚 FCM 的行为方式.

I'm having trouble figuring out how FCM behaves when I send a notification to an iOS device that is offline (e.g. in airplane mode, or turned off).

关于 time_to_live 属性提到 目前,iOS 上的通知消息不支持 time_to_live. 但没有提供对已完成操作的解释.我试过测试它,似乎推送通知有时会通过,有时不会,无论我将 time_to_live 属性设置为什么,尽管我不确定这是否到期节流或 FCM 方面发生的其他事情.

The documentation on the time_to_live property mentions that Currently, time_to_live is not supported for notification messages on iOS. but doesn't provide an explanation of what is done instead. I've tried testing it, and it seems like a push notification sometimes goes through, and sometimes does not, regardless of what I set the time_to_live property to be, although I'm not sure if that's due to throttling or something else happening on the FCM side.

相关地,我似乎无法让 delay_while_idle 属性在 iOS 上工作,尽管文档没有明确提到它不适用于 iOS - 手机时发送的通知即使我将 delay_while_idle 设置为 true,睡着了仍然会唤醒手机.

Relatedly, I can't seem to get the delay_while_idle property to work on iOS, although the documentation does not explicitly mention that it isn't available for iOS - notifications that are sent while the phone is asleep still wake the phone, even if I set delay_while_idle to be true.

有人知道这应该如何工作吗?

Does anyone have any insight into how this is supposed to work?

推荐答案

time_to_live AFAIK 适用于 Android 和 iOS.但是,由于 FCM 向 iOS 设备发送消息的过程是这样的:

The time_to_live is AFAIK applicable to both Android and iOS. However, since the process of sending the message to iOS devices for FCM goes like this:

应用服务器 > FCM 服务器 > APNs > iOS 设备

可以肯定地说,只有 FCM 服务器使用 time_to_live,根据它的 描述:

It is safe to say that only the FCM Server makes use of the time_to_live, as per it's description:

此参数指定如果设备离线,消息应在 FCM 存储中保留多长时间(以秒为单位).支持的最长生存时间为 4 周,默认值为 4 周.如需了解详情,请参阅设置消息的有效期.

环顾四周,发送到离线设备时 APNs 的行为是(来自 Apple 文档):

Looking around, the behavior for APNs when sending to offline devices is (from the Apple docs):

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

截至目前,delay_while_idle 现在已弃用.

As of now, delay_while_idle is now deprecated.

我知道您可以唤醒 iOS 手机(在线/连接到合适的网络)的方法是简单地priority设置为high.

The way I know that you could do to wake up an iOS phone (online/connected to a decent network) is to simply set the priority to high.

这篇关于iOS 离线时的 FCM 行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!