谷歌云消息生存时间 [英] Google cloud messaging time to live

查看:163
本文介绍了谷歌云消息生存时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是开发其采用GCM的Andr​​oid应用程序,但我想取消的消息传递,如果用户的手机不在线。有没有什么办法,以减少生存时间价值最小?


解决方案

我找到了答案@的 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
},

这篇关于谷歌云消息生存时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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