如何指定FCM消息的优先级? [英] How I can specify the priority on FCM message?

查看:288
本文介绍了如何指定FCM消息的优先级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用react-native-firebase来管理React-native应用程序上的通知. 当应用程序关闭时,我尝试在后台处理FCM消息,而不显示通知.

I'm using react-native-firebase to manage notifications on React-native app. I try to handle FCM message on the background when application is off without display the notification.

我正在使用react-native-firebase来管理React-native应用程序上的通知. 当我的应用程序关闭时,我尝试捕获FCM消​​息并唤醒我的应用程序而不显示任何通知,如此处所述

I’m using react-native-firebase to manage notifications on React-native app. When my app is off, I try to catch FCM messages and wake up my app without displaying any notification, just as described here https://rnfirebase.io/docs/v4.2.x/messaging/introduction#Data-only-messages 1.

在React Native Firebase文档中,他们说:

In React Native Firebase doc, they say :

您需要将FCM消息优先级指定为高才能使此功能正常工作.如果未设置此项,则不会授予该应用启动后台消息处理程序的权限.

You will need to specify the FCM message priority as high for this functionality to work. If this isn’t set, the app is not given permission to launch the background message handler.

我必须在哪里指定此优先级?我不明白这是怎么回事.

Where I must specify this priority ? I don’t understand how this works.

编辑1 :我试图在FCM消息上设置priority : "high",但是它仍然无法正常工作.我有与此问题相关的相同问题: https://github.com/转化酶/react-native-firebase/issues/500

Edit 1 : I tried to set priority : "high"on FCM message but it's still not working. I have the same problem related to this issue : https://github.com/invertase/react-native-firebase/issues/500

推荐答案

优先级被认为是特定于平台的配置.您可以为不同的平台设置不同的优先级.

The priority is considered as a platform specific config. You can set different priorities for different platforms.

例如,看下面的例子: ( 邮件优先级在Fcm文档中 )

For instance look at the example below: (Message priority in Fcm docs)

{
  "message":{
    "topic":"subscriber-updates",
    "notification":{
      "body" : "This week's edition is now available.",
      "title" : "NewsMagazine.com",
    },
    "data" : {
      "volume" : "3.21.15",
      "contents" : "http://www.news-magazine.com/world-week/21659772"
    },
    "android":{
      "priority":"normal"
    },
    "apns":{
      "headers":{
        "apns-priority":"5"
      }
    },
    "webpush": {
      "headers": {
        "Urgency": "high"
      }
    }
  }
}

这篇关于如何指定FCM消息的优先级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆