FCM notification messages not collapsing

2019-09-07 01:42发布

问题:

I noticed that when i send FCM payload when app is in background, i see the notification message being shown which is as per docs, but i see native notifications for every notification message received. When my app was in the background, i received 3 push messages (with notification payload) and i now see 3 native notifications in the notification tray. Why are they not getting collapsed ? By default, according to FCM docs, all notification messages are collapsible. Reference to the doc: https://firebase.google.com/docs/cloud-messaging/concept-options

I am using compile 'com.google.firebase:firebase-messaging:10.0.0' in my app\build.gradle

回答1:

In this case the "Tag" variable should be used. There should be same Tag set in the notifications payload. The complete notifications payload is as follows and it is working for me.

 "notification":{
    "title":"Huawei",
    "body":"21 Notification received", 
    "sound":"default",
    "badge":4,
    "tag":"1",
    "click_action":"OPEN_ACTIVITY_1"
     "icon":"fcm_push_icon" 
  }