c# – How can I receive multiple notifications by using GCM without replacing the precedent one?-ThrowExceptions

Exception or error:

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?

How to solve:

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

###

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.

Leave a Reply

Your email address will not be published. Required fields are marked *