Android GCM time_to_live 问题

标签 android google-cloud-messaging push-notification

我有一个与 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/

相关文章:

java - GCM getToken() 发送 java.io.IOException : TIMEOUT on some devices

android - 未收到 GCM 推送通知(全部通过)

java - 以编程方式添加证书颁发机构,同时保留 Android 系统 SSL 证书

android - IntentService 完成父 Activity

java - 有返回值的策略模式

android - 如何在不同的安卓手机上同时启动一个任务?

ios - Apple Push Notifications - 应用商店提交

ios - 选择推送通知的显示参数

java - OnClick 动态添加一个新行到 TableLayout 并从数据库中获取值将其显示在添加的行中并给出总计

android - 为什么与 ui 线程的通信只能通过处理程序?