Android FCM - how to show only one notification

后端 未结 3 841
鱼传尺愫
鱼传尺愫 2020-12-17 07:15

I\'m sending push notifications from FCM to an Android device, this is done by sending a POST message to FCM containing a JSON body.

If I send the same JSON body twi

3条回答
  •  清歌不尽
    2020-12-17 07:51

    Well, I kept digging and found the answer: it was not the "collapse_key", i was supposed to use the "tag" option in the notification instead.

    So by using this JSON only one notification is shown:

    {
        "notification": {
            "title": "MyAPP",
            "body": "Open MyAPP to access your data",
            "click_action" : "OPEN_MAINACTIVITY",
            "icon": "ic_launcher_red",
            "color": "#ff0000"
            "tag": "unique_tag"
        },
        "data": {
            "extra1":"sample1",
            "extra2":"sample2"
        },
        "registration_ids":[
            "--my_id--"
        ]
    }
    

    Hope this helps others!

    And if someone wishes to explain further on "collapse_key" I would be glad, clearly I misunderstood it.

提交回复
热议问题