GCM message is getting overridden

后端 未结 4 1682
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 11:43

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

4条回答
  •  盖世英雄少女心
    2021-01-14 12:12

    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

提交回复
热议问题