gpt4 book ai didi

android - FCM 推送高优先级 topic 自带延迟

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:10:50 24 4
gpt4 key购买 nike

我正在向订阅了一个优先级参数设置为的主题的一小组设备(少于 5 个)发送推送消息

High priority. FCM attempts to deliver high priority messages immediately, allowing the FCM service to wake a sleeping device when possible and open a network connection to your app server. Apps with instant messaging, chat, or voice call alerts, for example, generally need to open a network connection and make sure FCM delivers the message to the device without delay. Set high priority only if the message is time-critical and requires the user's immediate interaction, but beware that setting your messages to high priority contributes more to battery drain compared with normal priority messages.

但是当我将设备置于 IDLE 状态时,它会出现很大的延迟。在 Nougat 7.1 上延迟超过 10 分钟。这种类型的推送要求延迟小于 10 秒。

time_to_live 设置为 0 只能解决 Marshmallow 上的问题。牛轧糖仍然失败。

所以,我只看到 3 个可能的问题原因

  1. 发送到主题的消息不能是高优先级。但是向每台设备发送独立的消息会增加应用服务器的负载。我需要从 Firebase 数据库加载新 token ,因此结果将是 - 10 个 5 个用户而不是 1 个 HTTP 请求。

  2. 应用必须在白名单中。但是根据docs如果我使用 FCM,这是 Not Acceptable 。而且我不想要它,因为它会导调用池耗尽。

  3. 错误? https://github.com/firebase/quickstart-android/issues/100

如果首先是真正的原因,那么为什么没有在文档中描述它?

最佳答案

通过将 time_to_live 设置为 0 解决了这个问题。根据文档,此设置的优先级为“现在或从不”

Another advantage of specifying the lifespan of a message is that FCM never throttles messages with a time_to_live (TTL) value of 0 seconds. In other words, FCM guarantees best effort for messages that must be delivered "now or never." Keep in mind that a time_to_live value of 0 means messages that can't be delivered immediately are discarded. However, because such messages are never stored, this provides the best latency for sending notification messages.

UPD:仅针对 Marshmallow 解决。在牛轧糖上仍然是一个问题。

UPD2:只是不要使用主题,它们不是为了立即发送推送。

关于android - FCM 推送高优先级 topic 自带延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40590282/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com