且构网

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

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

更新时间:2022-01-26 22:53:33

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

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.

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