• <bdo id='XxPI0'></bdo><ul id='XxPI0'></ul>

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

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

        Firebase 消息传递 - 当应用程序在后台时创建平视显示

        时间:2023-07-30
        <tfoot id='TXkVW'></tfoot>

            <legend id='TXkVW'><style id='TXkVW'><dir id='TXkVW'><q id='TXkVW'></q></dir></style></legend>
              <tbody id='TXkVW'></tbody>
              <bdo id='TXkVW'></bdo><ul id='TXkVW'></ul>

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

                  本文介绍了Firebase 消息传递 - 当应用程序在后台时创建平视显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 FCM,当应用处于后台或未运行时,我会在系统托盘中收到推送通知.当应用程序处于前台时,我可以覆盖 onMessageReceived 并使用 NotificationCompat 创建自己的提醒通知.

                  With FCM I receive push notifications in the system tray when the app is in the background or not running. When the app is in the foreground I can override onMessageReceived and create my own heads-up notification with NotificationCompat.

                  当我的应用在后台或未运行时,有没有办法创建提醒通知?

                  Is there a way to create a heads-up notification when my app is in the background or not running?

                  谢谢

                  这里是我通过 curl 使用的消息负载以供参考 https://fcm.googleapis.com/fcm/send

                  For reference here is the message payload I am using via curl to https://fcm.googleapis.com/fcm/send

                  {
                    "to":"push-token",
                      "content_available": true,
                      "priority": "high",
                      "notification": {
                        "title": "Test",
                        "body": "Mary sent you a message!",
                        "sound": "default"
                      },
                      "data": {
                        "message": "Mary sent you a Message!",
                        "notificationKey":"userID/notification_type",
                        "priority": "high",
                        "sound": "default"
                      }
                  }
                  

                  推荐答案

                  只有当您的应用程序处于后台或未运行时,您才会收到提醒通知.如果您的手机没有被使用,那么您将收到系统托盘通知或锁定屏幕通知.

                  You will get heads up notification only if you are using some other app while your app is in background or not running. If your phone is not being used then you will receive system tray notification or lock screen notification.

                  如果您使用应用服务器通过 http 协议发送推送通知,那么您甚至可以在发送到 fcm 端点的 json 数据中将优先级设置为高.

                  如果您使用的是 firebase 控制台,请在高级通知部分设置下确保优先级较高.

                  高优先级将确保您在大多数情况下都能收到提醒通知.

                  High priority will ensure you receive heads up notifications in most cases.

                  编辑:这就是您编辑后的 json 应该是什么样子才能成功测试 -

                  EDIT: This is how your edited json should look like for successful test -

                  {
                    "to":"push-token",
                      "priority": "high",
                      "notification": {
                        "title": "Test",
                        "body": "Mary sent you a message!",
                        "sound": "default",
                        "icon": "youriconname"
                      }
                  }
                  

                  youriconname 是您要设置为通知图标的可绘制资源的名称.

                  youriconname is the name of drawable resource that you want to set as your notification icon.

                  出于测试目的,我省略了数据.就这么多应该给你提醒通知.

                  这篇关于Firebase 消息传递 - 当应用程序在后台时创建平视显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Firebase 两次发送推送通知 下一篇:如何从 Android 中的 FCM 数据消息中获取价值?

                  相关文章

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

                    <legend id='uPAXR'><style id='uPAXR'><dir id='uPAXR'><q id='uPAXR'></q></dir></style></legend><tfoot id='uPAXR'></tfoot>

                      <bdo id='uPAXR'></bdo><ul id='uPAXR'></ul>