4

I'm developing an app using Google Cloud Messaging with the latest Google Play Services version.

If I turn my device's network connections off, all messages that should have been received during the time I have no Internet access are stored in the server, and I do not get them until a new one arrives when I have turned one of my network connections back on.

So, if I receive 20 new messages during the night, when I have my WiFi/3G off, when I switch my WiFi on in the morning I get no messages, and when the first new message arrives I get the 21 push notifications at once.

The question is, then... is there any way around this? Is it a problem of my implementation or this is the expected behaviour and I should have to find some workaround?

Thanks!

Small edit: I do not get the 21 notifications at once, since the push messages I send are collapsible, but I do not get the collapsed message until a new one arrives, anyway.

luthier
  • 2,674
  • 4
  • 32
  • 35
  • Υou want to dispose those 20 messages or what? – Pavlos Aug 17 '13 at 09:30
  • No, I want to receive then when I turn my WiFi on again in the morning, without having to wait for a new one to arrive and then get them all together. Right now, if I don't get any messages in the morning, the 20 night messages are stuck in some kind of push message limbo :-) – luthier Aug 17 '13 at 11:40
  • http://stackoverflow.com/questions/13835676/google-cloud-messaging-messages-sometimes-not-received-until-network-state-cha – Pavlos Aug 17 '13 at 16:47
  • Thank you Pavlos, I think it's not *exactly* the same problem, and anyway, I was hoping for some kind of workaround because, you know, lots of apps use push notifications and I get their messages in the morning, so either it's a problem with my implementation or there is some kind of workaround for it... anyway, thanks for the link! – luthier Aug 18 '13 at 10:04
  • Maybe it's a problem with your current implementation, I've used push notifications and they arrive as soon as I get internet connection, can you post code to take a look? – Raúl Juárez Aug 30 '13 at 16:46
  • Post your server-side code for adding parameters to the messages, it might be a problem with the time_to_live or delay_while_idle parameters. – npace Sep 02 '13 at 06:52

1 Answers1

3

This seems like an issue of time_to_live parameter on the message payload. Quoting Android Docs on the same:

time_to_live: How long (in seconds) the message should be kept on GCM storage if the device is offline.(default time-to-live is 4 weeks).

Good Luck !

Community
  • 1
  • 1
Gaurav Arora
  • 17,124
  • 5
  • 33
  • 44
  • Thanks! You were right, it **was** an issue with the `time_to_live` parameter. I was manually setting it to 2419200 and there seems to be a bug with that, because I just removed the parameter altogether and now it's working. Thanks for the tip! – luthier Sep 04 '13 at 09:28
  • is collapse_key is same for all message or different for all all message because i try to set it same for all message then i got only a last message. – Krunal Shah Sep 09 '15 at 05:34