<tfoot id='uYdvu'></tfoot>
  • <legend id='uYdvu'><style id='uYdvu'><dir id='uYdvu'><q id='uYdvu'></q></dir></style></legend>
  • <small id='uYdvu'></small><noframes id='uYdvu'>

      1. <i id='uYdvu'><tr id='uYdvu'><dt id='uYdvu'><q id='uYdvu'><span id='uYdvu'><b id='uYdvu'><form id='uYdvu'><ins id='uYdvu'></ins><ul id='uYdvu'></ul><sub id='uYdvu'></sub></form><legend id='uYdvu'></legend><bdo id='uYdvu'><pre id='uYdvu'><center id='uYdvu'></center></pre></bdo></b><th id='uYdvu'></th></span></q></dt></tr></i><div id='uYdvu'><tfoot id='uYdvu'></tfoot><dl id='uYdvu'><fieldset id='uYdvu'></fieldset></dl></div>
        • <bdo id='uYdvu'></bdo><ul id='uYdvu'></ul>

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

        时间:2023-07-29

        <i id='BlgNf'><tr id='BlgNf'><dt id='BlgNf'><q id='BlgNf'><span id='BlgNf'><b id='BlgNf'><form id='BlgNf'><ins id='BlgNf'></ins><ul id='BlgNf'></ul><sub id='BlgNf'></sub></form><legend id='BlgNf'></legend><bdo id='BlgNf'><pre id='BlgNf'><center id='BlgNf'></center></pre></bdo></b><th id='BlgNf'></th></span></q></dt></tr></i><div id='BlgNf'><tfoot id='BlgNf'></tfoot><dl id='BlgNf'><fieldset id='BlgNf'></fieldset></dl></div>
      2. <tfoot id='BlgNf'></tfoot>

            <legend id='BlgNf'><style id='BlgNf'><dir id='BlgNf'><q id='BlgNf'></q></dir></style></legend>

            <small id='BlgNf'></small><noframes id='BlgNf'>

              <tbody id='BlgNf'></tbody>
              <bdo id='BlgNf'></bdo><ul id='BlgNf'></ul>

                  本文介绍了Android FCM - 如何只显示一个通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在从 FCM 向 Android 设备发送推送通知,这是通过向 FCM 发送包含 JSON 正文的 POST 消息来完成的.

                  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.

                  如果我两次发送相同的 JSON 正文,Android 设备将显示两个通知(或三个,或四个,...).但我希望它只显示一个.

                  If I send the same JSON body twice, the Android device will show two notifications (or three, or four, ...). But i want it to show only one.

                  collapse_key"应该可以解决这个问题,对吧?(FCM 文档)

                  The "collapse_key" should solve this, right? (FCM Documentation)

                  但是应该在哪里或如何插入呢?

                  But where or how should it be inserted?

                  这个 SO 问题回答了这个问题,但没有给出示例:Can FCMAndroid 上的通知会覆盖之前的通知吗?

                  This SO question answers this but no example is given: Can FCM notification on Android overwrite previous one?

                  当前 JSON 正文:

                  Current JSON body:

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

                  我已经尝试了多种方法来包含collapse_key",但到目前为止还没有运气.仍然是多个通知.欢迎任何帮助.

                  I have tried in many ways to include the "collapse_key" but no luck so far. Still multiple notifications. Any help is welcome.

                  推荐答案

                  好吧,我一直在挖掘并找到答案:不是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.

                  这篇关于Android FCM - 如何只显示一个通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:ios10、Swift 3 和 Firebase 推送通知 (FCM) 下一篇:尝试在空对象引用上调用虚拟方法 com.google.firebase.iid.FirebaseInstanceId.g

                  相关文章

                  1. <tfoot id='tn9TV'></tfoot>

                  2. <legend id='tn9TV'><style id='tn9TV'><dir id='tn9TV'><q id='tn9TV'></q></dir></style></legend>
                      <bdo id='tn9TV'></bdo><ul id='tn9TV'></ul>
                  3. <small id='tn9TV'></small><noframes id='tn9TV'>

                      <i id='tn9TV'><tr id='tn9TV'><dt id='tn9TV'><q id='tn9TV'><span id='tn9TV'><b id='tn9TV'><form id='tn9TV'><ins id='tn9TV'></ins><ul id='tn9TV'></ul><sub id='tn9TV'></sub></form><legend id='tn9TV'></legend><bdo id='tn9TV'><pre id='tn9TV'><center id='tn9TV'></center></pre></bdo></b><th id='tn9TV'></th></span></q></dt></tr></i><div id='tn9TV'><tfoot id='tn9TV'></tfoot><dl id='tn9TV'><fieldset id='tn9TV'></fieldset></dl></div>