I am using GCM push notification to pass some notification to the user. My problem is when am sending single message then this works fine if send more than one then the last
Yes agree with Dipo's answer. According to Android Notification Developer Guide This is being overridden due to same notification id for more than one notification.SO the last message is being received on receiver end. You need to Implement random unique Notification id for each notifications. There are number of ways to implement this . You can use this
int notificationId = new Random().nextInt();
You can also use system time in Mili Seconds for Notification id.Then you need to pass this unique Notification ID to notificationManager.notify()
Cheers ! Keep Coding
used this coding in your notification
int requestID = (int) System.currentTimeMillis();
PendingIntent intent = PendingIntent.getActivity(context, requestID,
notificationIntent,0 );
then your notification will not override i hope this will help u
Make notification id unique for each message. Due to this, it's being overridden.
Quite late to answer for the thread but felt it will be helpful for someone. The same implementation works fine for FCM firebase implementation as well
// Get a random value
int notificationId = new Random().nextInt();
// Add the notification ID which is unique as a first value of the notify method.
notificationManager.notify(notificationId, notificationBuilder.build());