是否可以在node.js中运行Firebase消息传递? [英] Is it possible to run firebase messaging in node.js?
问题描述
在我执行的nodejs下:
under nodejs i did :
npm install firebase --save
然后我做
var firebase = require("firebase");
// Initialize Firebase
var config = {
apiKey: "...",
authDomain: "...,
databaseURL: "....",
projectId: "....",
storageBucket: "....",
messagingSenderId: "...."
};
firebase.initializeApp(config);
const messaging = firebase.messaging(); << crash here
但说firebase.messaging is not a function
他们是否可以在node.js中运行firebase消息以监听通知?
他们是文件/node_modules/firebase/firebase-messaging.js
,但是很模糊,我听不懂它的作用
Is their any way to run firebase messaging in node.js to listen notification ?
their is the file /node_modules/firebase/firebase-messaging.js
but it's obfuscate and i can't understand it and what it's does
推荐答案
有两种适用于Node的Firebase SDK:
There are two Firebase SDKs that will work on Node:
- Firebase Web SDK ,其针对客户端设备,例如浏览器和Node.js物联网设备.
- Firebase Admin SDK ,旨在在受信任的设备上运行,例如您托管的Node.js服务器.
- the Firebase Web SDK, which is targeted towards client-side devices such as browsers and Node.js IoT devices.
- the Firebase Admin SDK, which is meant to run on trusted devices, such as a Node.js server that you host.
仅通过 支持对通过Firebase Cloud Messaging发送消息包含在Firebase Admin SDK的Node.js中..
仅在Firebase Web SDK中包括支持通过Firebase Cloud Messaging接收消息.无法在Node.js中接收FCM消息.
Supporting for receiving messages through Firebase Cloud Messaging is only included in the Firebase Web SDK. It is not possible to receive FCM messages in Node.js.
If you want to send message to a Node.js process, I'd recommend you look into the Firebase Realtime Database.
这篇关于是否可以在node.js中运行Firebase消息传递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!