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

不羁岁月 提交于 2019-12-10 14:47:50

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/21163399/how-to-handle-multiple-push-notifications-in-android-using-gcm-on-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!