How to stop new push notification being replaced by the old one in Firebase?

前端 未结 2 1241
迷失自我
迷失自我 2020-12-21 11:53

When I trigger a push notification then the old one is replaced by new one. But I want it should add to that old notification.

My MyFirebaseMessaging class is:

相关标签:
2条回答
  • 2020-12-21 12:13

    you have to do like below

    private final static AtomicInteger c = new AtomicInteger(0);
    
        public static int getID() {
            return c.incrementAndGet();
        }
    

    your list line should be replace with below

    notificationManager.notify(getID(), notificationBuilder.build());
    
    0 讨论(0)
  • 2020-12-21 12:21

    new push notification is replaced the old one in firebase push notification in my application,How i will stop this

    You need to pas different notificationID in notificationManager.notify()

    SAMPLE CODE

    Date myDate = new Date();
    int myNotificationId = Integer.parseInt(new SimpleDateFormat("ddhhmmss",  Locale.US).format(myDate));
    notificationManager.notify(myNotificationId,notificationBuilder.build());
    
    0 讨论(0)
提交回复
热议问题