android - How I can specify the priority on FCM message?
问题描述
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.
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.
In React Native Firebase doc, they say :
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.
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
解决方案
Using "priority":10 did the trick for me.
curl -X POST --header "Authorization: key=<your_key>" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d {"data":{"body":"Test body from curl"},"registration_ids":["<reg_ids>"],"apns":{"headers":{"apns-priority":"10"}},"webpush":{"headers":{"Urgency": "high"}},"android":{"priority":"high"},"priority":10}
推荐阅读
- python - 如何用 iloc 重写这个表达式
- javascript - 如何从 Fetch API 调用返回 json
- android - 问题构建应用程序,云存储问题
- python - 从 +250.000 帧创建 7 小时视频
- konvajs - 如何在 konva js 中覆盖(或更新)宽度和 hiehgt 的形状?
- r - 如何强制评估悬挂的 R 表达式
- excel - 使用 VBA 从 Finviz 抓取数据。除了少数小问题外,代码大部分都可以工作?
- flutter - 如何在颤动中显示所有图像格式?
- android - 在 Jetpack Compose 中截取 Webview (AndroidView)
- python - 如何返回格式字符串以及为什么我的按钮不显示?