无论如何,使用不带Firebase数据库的FCM可以将通知从一台设备发送到另一台设备吗? [英] is there anyway to send notification from one device to other device using FCM without Firebase Database?

查看:59
本文介绍了无论如何,使用不带Firebase数据库的FCM可以将通知从一台设备发送到另一台设备吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用FCM设置一个Android应用程序通知,以便它可以触发该应用程序使用同一应用程序将通知发送到其他设备(接收方)并接收通知.我想使用FCM但不使用Firebase数据库,而是使用PostGreSQL/其他数据库.怎么做?也可以在AdonisJS中实现Firebase吗?因为我将其用于服务器端.

解决方案

Firebase Cloud Messaging不支持直接向设备发送消息.将消息发送到设备(称为下游消息)要求您指定FCM服务器密钥,并且(如其名称所暗示的)该密钥应仅在服务器或其他受信任的环境上使用.

这样做的原因是,拥有项目的FCM服务器密钥允许您将任何消息发送到该项目中的任何和所有设备,因此,在受信任的环境之外使用此消息将是安全问题. /p>

但是不需要使用Firebase数据库发送FCM消息.验证此问题的最简单方法是通过命令行curl调用发送消息,如下所示: 解决方案

Firebase Cloud Messaging does not support directly sending messages to a device. Sending a message to a device (known as a downstream message) requires that you specify the FCM server key, and (as its name implies) that key should only be used on a server, or otherwise trusted environment.

The reason for this is that having the FCM server key for a project allows you to send any message to any and all of the devices in that project, so having this available outside of a trusted environment would be a security concern.

But there is no need to use the Firebase Database to send FCM message. The simplest way to verify this is to send a message through a command line curl call, like shown here: How can I send a Firebase Cloud Messaging notification without use the Firebase Console? You can also implement the code to send a message in Cloud Functions or your own favorite server-side environment without a database. You'll just have to pass in the target of where to send the message into the function.

这篇关于无论如何,使用不带Firebase数据库的FCM可以将通知从一台设备发送到另一台设备吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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