Firebase sends multiple push notifications instead of styling or replacing

I am trying to create a previous push notification stack with a new one or replace it on the taskbar for Android.

I am not sure how to do this, since the push notification sends back both data objects and notifications, and from what I understand, the notification is sent directly to the system tray. If so, how can I stop the notification independently. Some users will receive 5-10 notifications, and this will continue.

EDIT:

I tried collapse_key, but it still does not replace previous notifications with the same key ... Am I doing it wrong somehow here?

method: 'POST', uri: 'https://gcm-http.googleapis.com/gcm/send', headers: { 'Content-Type': 'application/json', 'Authorization': authorize //GOOGLE API KEY }, body: JSON.stringify({ "registration_ids": [otherUserResult.reg_id], "collapse_key": "follow", "data": { "notifyToUserId": to, "notifyFromId": from, "notifyMsg": msg, "notifyItemPicture": itemPic, "notifyItemName": itemName, "notifyFromName": fromName, "notifyType": type, "dateNotified": dateNotified }, "notification": { "title": fromName, "body": notifyMsg, "icon" : "ic_pushnotify" }, "priority": "high", "content_available": true 
+5
source share
1 answer

They worked for me when I included 2 lines in my "notifications":

 collapse_key: 'your_app_unique_string', tag: 'your_app_unique_string' 

Thus, the complete code will be:

 var payload = {notification: { title: "Mensaje de "+message.name, body: message.text, sound: "default", collapse_key: 'charlero', tag: 'charlero' } }; 
0
source

Source: https://habr.com/ru/post/1257858/


All Articles