Search code examples
androidandroid-c2dm

How to set a timeout/expiration on a C2DM message?


Is there a TTL or expiration or some sort of timeout feature for C2DM messages?

I would like the C2DM message to be received within 10 minutes by the device, any longer (ie: if their phone is off) and the C2DM message should not be received by the device.

I could probably implement something in the device to ignore any C2DM messages if they are old, but I'm not sure how accurate that would be with different device time settings.

A TTL flag on the C2DM message sent to google would be perfect, but not sure if they support this.

Cheers! Dave


Solution

  • C2DM does not have such a feature. Please have a look here:

    how to set valid time period for android c2dm message?

    Update:

    Google just released a new version of c2dm called "Google Cloud Messaging (GCM)". With GCM it is possible to use a timeout for your messages:

    enter image description here

    I really recommend the Google I/O 2012 "Google Cloud Messaging for Android" session available here: http://www.youtube.com/watch?v=YoaP6hcDctM

    Additionally you can read through the GCM ttl section: http://developer.android.com/guide/google/gcm/adv.html#ttl