Right now I am using 3 devices for testing: Samsung S7500, Galaxy Mexus, HTC explore. If the devices are active, then I am receiving push notification in all three devices. If it is in idle state(locked/sleep), then also I am receiving push notification in all three devices. But if it is offline when the push message has been send, the time I am getting online should receive all pending notifications as per the documentation. But in this case I am not receiving notification in all the devices. Specially in Galaxy Nexus, sometime I am receiving if it is in idle state and sometime not. Where I am getting wrong? Can anyone help me?
String posted to GCM server from Third party server(.Net) end: where "i" is the current time.
String postdata= "collapse_key=score_update"+i+"&time_to_live=2419200&delay_while_idle=1&data.message="+ message + "&data.time=" + System.DateTime.Now.ToString()
+ "®istration_id=" + deviceToken + "";
Mentioned all required permissions in manifest as per documentation including Wakelock. This is my code for notiication in GCMIntentService class:
int icon = R.drawable.notif;
long when = System.currentTimeMillis();
NotificationManager notificationManager =(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification();
Intent notificationIntent = new Intent(context, DemoActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, (int) when,
notificationIntent,0);
RemoteViews contentView = new RemoteViews(getPackageName(),R.layout.notify);
contentView.setImageViewResource(R.id.ImageViewpnotify, icon);
contentView.setTextViewText(R.id.TextViewpnotify, message);
notification.contentView = contentView;
notification.contentIntent= intent;
notification.icon = icon;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.ledARGB = 0xffff0000;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.ledOnMS = 100;
notification.ledOffMS = 100;
notificationManager.notify((int)when, notification);