是否可以在node.js中运行Firebase消息传递? [英] Is it possible to run firebase messaging in node.js?

查看:69
本文介绍了是否可以在node.js中运行Firebase消息传递?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我执行的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:

  • 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.

如果要向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屋!

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