Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google cloud messaging time to live

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?

like image 946
sider Avatar asked Jan 30 '26 00:01

sider


1 Answers

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
},
like image 114
sider Avatar answered Feb 01 '26 15:02

sider