Add a new notification when push notification is received (not replace the previous)

前端 未结 6 1877
予麋鹿
予麋鹿 2021-02-02 16:59

I am using push notifications in my app. I need to display a notification when a push notification delivered. If I send another notification (without clearing the previous notif

6条回答
  •  死守一世寂寞
    2021-02-02 17:50

    You need to supply a different ID as the notification ID each time. The best approach would be to send an ID field to GCM which can be then accessed via Intent.getExtras().getInt() in your GCMIntentService's onMessage() method.

    If this is not possible, I'd suggest using something like (int)Math.random()*10 to generate a random integer number as your notification ID. This will (partially) ensure that your notifications will not replace each other.

提交回复
热议问题