Android GCM time_to_live问题 [英] Android GCM time_to_live issue

查看:87
本文介绍了Android GCM time_to_live问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与 time_to_live 有关的问题。我在设备打开时收到消息,但当设备处于脱机状态时,我没有收到消息,或者至少在前15分钟内没有收到消息。我正在发送带有delay的消息while idle true和 time_to_live 2419200.任何想法发生了什么,也许我误读了文档。

解决方案

来自文档:


delay_while_idle :如果包括,则表示如果设备空闲,则不应该立即发送消息
。服务器将等待
设备激活,然后只发送每个
collapse_key值的最后一条消息。可选的。默认值为false,
并且必须是JSON布尔值。


$ b time_to_live :邮件应该多长时间(以秒为单位)如果设备处于离线状态,请保存在GCM
存储中。可选(默认生存时间为4
周,并且必须设置为JSON编号)。如果您使用此参数
,您还必须指定一个collapse_key。

您不需要设置time_to_live值到2419200.这是默认值。但是,如果您设置了它,您还应该设置collapse_key。


collapse_key

strong>:任意字符串(例如Updates Available),用于在设备为
脱机时折叠一组类似消息,以便仅将最后一条消息发送到客户端。这
旨在避免当
重新联机时向手机发送太多消息。请注意,由于不能保证发送消息的订单
,所以最后消息实际上可能不是应用服务器发送的
最后消息。有关此主题的更多讨论,请参阅
的高级主题。可选的,除非您使用
time_to_live参数 - 在这种情况下,您还必须指定
collapse_key。

有关详情,请再次查看教程


I have a problem related to time_to_live. I get messages when the device is on, but when it is offline I don't get the message or at least it is not sent in the first 15 minutes. I'm sending the message with delay while idle true and time_to_live 2419200. Any ideas what is happening, maybe I misread the documentation.

解决方案

From the documentation :

delay_while_idle : If included, indicates that the message should not be sent immediately if the device is idle. The server will wait for the device to become active, and then only the last message for each collapse_key value will be sent. Optional. The default value is false, and must be a JSON boolean.

time_to_live : How long (in seconds) the message should be kept on GCM storage if the device is offline. Optional (default time-to-live is 4 weeks, and must be set as a JSON number). If you use this parameter, you must also specify a collapse_key.

You don't need to set the time_to_live value to 2419200. It is the default value.However, if you set it you should also set the collapse_key.

collapse_key : An arbitrary string (such as "Updates Available") that is used to collapse a group of like messages when the device is offline, so that only the last message gets sent to the client. This is intended to avoid sending too many messages to the phone when it comes back online. Note that since there is no guarantee of the order in which messages get sent, the "last" message may not actually be the last message sent by the application server. See Advanced Topics for more discussion of this topic. Optional, unless you are using the time_to_live parameter—in that case, you must also specify a collapse_key.

For more details check tutorial again.

这篇关于Android GCM time_to_live问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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