While my device has not internet connection, I am sending message from server to application with GCM. After that, when device connect the internet, i can't get the message. Is it normal?
from http://developer.android.com/guide/google/gcm/adv.html
"If the device is not connected to GCM, the message will be stored until a connection is established (again respecting the collapse key rules). "
My messages have same collapse key; but still I have to get only 1 message when device is connected.
you can get all the messages send to your device.
GCM server keeps account of your all messages send to your device. And it shows these in notification area whenever device get connected to Internet.
You are getting only one message because you are assigning same NOTIFICATION ID in notify() function of your code
your code probably using this :
// 0 is notification id
notificationManager.notify(0, notification);
change your NOTIFICATION ID everytime to get all messages in notification area.
Such As :
static int NOTIFICATION_ID = 0;
if (NOTIFICATION_ID > 1073741824) {
NOTIFICATION_ID = 0;
}
notificationManager.notify(NOTIFICATION_ID++, notification);
if clause keeps you safe from overflow of int value. You can ignore it according to your requirement.
I have already tested this scenario. Now its your turn.
Happy to Help !!