Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle multiple push notifications in android using GCM on phonegap

When a push notifications is arrived, if user is not available to see the notification. he got another notification the previsous is getting updated with the new one. But it should not update with latest one. we need to display each notification separately is that possible using GCM?

I have used Phonegap to develop the application

like image 994
icemaker Avatar asked Jan 16 '14 13:01

icemaker


2 Answers

The PushPlugin supports sending notification Ids in the payload. When sendingthe GCM message from your server, include a unique data.notId along with data.message and data.title, and you will have separate notifications.

like image 64
Jesper We Avatar answered Nov 03 '22 18:11

Jesper We


Well, if you look at the implementation of PushPlugin, you'll see that they use a constant notification ID:

public static final int NOTIFICATION_ID = 237;
...
mNotificationManager.notify((String) appName, NOTIFICATION_ID, mBuilder.build());

This would cause every new notification to overwrite the existing one. That's why only the last notification is displayed.

If you want to change the behavior, you have to change the code to use a unique notification ID for each notification.

like image 36
Eran Avatar answered Nov 03 '22 17:11

Eran