Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I receive multiple notifications by using GCM without replacing the precedent one?

Tags:

I'm working on a project which receive notification from GCM server.

I've got the registration ID from GCM server and i send it to my server application which save it in the database.

My device receive the message but when I try to send another one, the precedent is replaced.

I know that we've 2 types of message:

  • Collapsible "send to sync"
  • Non-Collapsible

So without changing the name of the message, how can I get two message send at different time?

UPDATE 1:

When my device is offline (for example airport mode activated), I try to send for example 2 messages from my application server to Google server (I read that Google stores all the messages). But when I desactivate this mode, I receive only the last message sent.

I use different collapse_key for different message and I receive all of them (of course when the device online).

Is anybody knows how can I fix this?

like image 802
13KZ Avatar asked Dec 07 '12 13:12

13KZ


2 Answers

The collapse key is relevant only to messages that were sent to the GCM server but haven't reached the destination device yet (if more than one such message has the same collapse key, only one of them will be sent to the device when it becomes online).

In your question you describe a different situation - the first message is received by the device and then the second message is received by the device and replaces the original message. That has nothing to do with GCM. It has to do with the way your application handles the received messages. For example, if your application code that receives the message displays is as a notification, it's up to you to decide whether a new message will override the existing notification or create a new notification.

like image 158
Eran Avatar answered Nov 08 '22 17:11

Eran


You need to make sure that the value of the 'collapse_key' field in each message is different

like image 38
NickT Avatar answered Nov 08 '22 18:11

NickT