且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

谷歌云消息生存时间

更新时间:2022-11-22 22:34:46

我找到了答案@的 http://developer.android.com/google/gcm/adv.html


  

指定过期日期的消息的另一个优点是
  0的time_to_live值GCM永远不会油门的邮件
  秒。换句话说,GCM将保证消息尽力而为
  必须交付机不可失,时不再来。请记住,一个
  0 time_to_live值表示无法传递的消息
  立即将被丢弃。然而,因为这样的消息是
  不被存储,这提供了***的延迟发送
  通知。


  
  

下面是一个JSON格式的请求的例子,包括TTL:


块引用>
  {
  collapse_key的:演示,
  delay_while_idle:真实,
  registration_ids:XYZ]
  数据:{
    KEY1:值1
    KEY2:VALUE2
  },
  time_to_live:3
},

I was developing android application which uses GCM, but I want to cancel message delivery if user phone is not online. Is there any way to decrease time to live value to minimum?

I found an answer @ http://developer.android.com/google/gcm/adv.html

Another advantage of specifying the expiration date for a message is that GCM will never throttle messages with a time_to_live value of 0 seconds. In other words, GCM will guarantee 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 will be discarded. However, because such messages are never stored, this provides the best latency for sending notifications.

Here is an example of a JSON-formatted request that includes TTL:

{
  "collapse_key" : "demo",
  "delay_while_idle" : true,
  "registration_ids" : ["xyz"],
  "data" : {
    "key1" : "value1",
    "key2" : "value2",
  },
  "time_to_live" : 3
},