从Firebase控制台发送静默推送通知 [英] Send silent push notification from Firebase console

查看:500
本文介绍了从Firebase控制台发送静默推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图证明我一直在努力的概念,这涉及我的应用程序收到无声通知。我正在使用Firebase云消息传递,因为它比开发人员的本机APN更少开销。



我知道FCM支持在您自己的后端自己构建有效负载时的静默通知,这当然是我的意图。但是,我想确保我可以对此通知做我想做的事情,因此我希望在我花时间编写后端之前使用FCM控制台来证明它。



<我已经设法从这里发送标准通知,但不是沉默的通知。即使我包含 content-available 标志,我仍然会收到提醒。我认为这是由于FCM始终在JSON中包含 alert 参数。有没有办法在测试控制台中禁用它?



非常感谢,

解决方案

无法从Firebase控制台发送与标准类型不同的通知。



一种非常方便的方法是使用邮递员或卷曲并设置授权标题。

  curl -HContent-type:application / json-H授权:key =< YOUR-API-KEY> -X POST -d'{data:{foo:1,bar:2},to:< YOUR-DEVICE-TOKEN>}'https:// fcm .googleapis.com / fcm /发送


Trying to prove a concept I've been working on for a while, which involves my app recieving a silent notification. I am using Firebase Cloud Messaging as it has less overhead than native APNs for the developer.

I know FCM supports silent notifications when you build the payload yourself on your own backend, which is of course my intention. However, I want to make sure I can do what I want to do with this notification, and therefore want to prove it using the FCM console before I spend time writing my backend.

I have managed to send standard notifications from here, but not silent ones. Even when I include the content-available flag I'm still alerted. I think this is due to FCM always including the alert parameter in the JSON. Is there a way to disable this in the test console?

Many Thanks,

解决方案

There is no way to send notifications different from the standard kind from the Firebase Console.

A quite convenient way is to use Postman or curl with a set Authorization 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

这篇关于从Firebase控制台发送静默推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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