我有一个与 time_to_live
有关的问题。我在设备开启时收到消息,但在设备离线时我收不到消息,或者至少在前 15 分钟内没有发送消息。我在空闲时延迟发送消息 true 和 time_to_live
2419200。任何想法发生了什么,也许我误读了文档。
最佳答案
来自文档:
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.
您不需要将 time_to_live 值设置为 2419200。这是默认值。但是,如果您设置它,您还应该设置 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.
更多详情请查看tutorial再次。
关于Android GCM time_to_live 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12354690/