从 Firebase 控制台发送静默推送通知
Send silent push notification from Firebase console
试图证明我研究了一段时间的概念,其中涉及我的应用程序接收静默通知。我正在使用 Firebase 云消息传递,因为它比开发人员的本机 APN 开销更少。
我知道当您在自己的后端自行构建负载时,FCM 支持静默通知,这当然是我的意图。但是,我想确保我可以用这个通知做我想做的事情,因此我想在花时间编写我的后端之前使用 FCM 控制台来证明它。
我已经设法从这里发送标准通知,但不是静默通知。即使我包含 content-available
标志,我仍然会收到警报。我认为这是由于 FCM 总是在 JSON 中包含 alert
参数。有没有办法在测试控制台中禁用它?
非常感谢,
无法从 Firebase 控制台发送不同于标准类型的通知。
一个非常方便的方法是使用 Postman 或 curl 设置授权 Header.
curl -H "Content-type: application/json" -H "Authorization:key=<YOUR-API-KEY>" -X POST -d '{ "data": { "foo": "1","bar": "2"},"to" : "<YOUR-DEVICE-TOKEN>"}' https://fcm.googleapis.com/fcm/send
您实际上可以从 FCN 发送静默通知。检查 here.
Note: On iOS, set content_available when the app server needs to send a send-to-sync message. An inactive client app executes your logic in the background, while an app in the foreground passes the message to didReceiveRemoteNotification:.
请注意,您必须使用的密钥是 content_available
,带下划线;与带有连字符的 content-available
不同。
试图证明我研究了一段时间的概念,其中涉及我的应用程序接收静默通知。我正在使用 Firebase 云消息传递,因为它比开发人员的本机 APN 开销更少。
我知道当您在自己的后端自行构建负载时,FCM 支持静默通知,这当然是我的意图。但是,我想确保我可以用这个通知做我想做的事情,因此我想在花时间编写我的后端之前使用 FCM 控制台来证明它。
我已经设法从这里发送标准通知,但不是静默通知。即使我包含 content-available
标志,我仍然会收到警报。我认为这是由于 FCM 总是在 JSON 中包含 alert
参数。有没有办法在测试控制台中禁用它?
非常感谢,
无法从 Firebase 控制台发送不同于标准类型的通知。
一个非常方便的方法是使用 Postman 或 curl 设置授权 Header.
curl -H "Content-type: application/json" -H "Authorization:key=<YOUR-API-KEY>" -X POST -d '{ "data": { "foo": "1","bar": "2"},"to" : "<YOUR-DEVICE-TOKEN>"}' https://fcm.googleapis.com/fcm/send
您实际上可以从 FCN 发送静默通知。检查 here.
Note: On iOS, set content_available when the app server needs to send a send-to-sync message. An inactive client app executes your logic in the background, while an app in the foreground passes the message to didReceiveRemoteNotification:.
请注意,您必须使用的密钥是 content_available
,带下划线;与带有连字符的 content-available
不同。