Can FCM notification on Android overwrite previous one?

Romulus Urakagi Ts'ai picture Romulus Urakagi Ts'ai · Sep 30, 2016 · Viewed 8.5k times · Source

I'm using FCM to send notifications to Android devices. When the app is in background, if I send 10 notifications, the devices will show up 10 entries on the notification bar.

I want FCM to make only one entry on notification bar, i.e. the newer one will overwrite old ones. I don't find a key to set this at https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream.

Is there a way to do, or it is impossible? Thanks.

Answer

Ayo Makanjuola picture Ayo Makanjuola · Jan 27, 2018

To achieve this, in your notification payload, use the tag key

{
    "notification" : {
        "title" : "Notification Title",
        "body" : "Notification Body",
        "tag" : "your_unique_tag"
    }
}

Cheers.