且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android FCM - 如何只显示一个通知

更新时间:2022-12-19 21:14:13

好吧,我一直在挖掘并找到答案:不是collapse_key",我应该在通知中使用tag"选项.

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.

因此,使用此 JSON 只会显示一个通知:

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!

如果有人想进一步解释collapse_key",我会很高兴,显然我误解了.

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