简体   繁体   English

如何从云功能通过 Firebase 云消息传递发送通知?

[英]How can I send a Notification via Firebase Cloud Messaging from a cloud function?

The documentation at https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.md#getmessaging does not explain where the "firebase-admin/messaging" module is. https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.md#getmessaging上的文档没有解释“firebase-admin/messaging”模块的位置。 What is the require path to get this module?获取此模块的 require 路径是什么?

for instance例如

const { getMessaging } = require("firebase-admin/messaging");

does not work.不起作用。

I also looked into the cloud functions sdk at https://firebase.google.com/docs/reference/functions#functions.pubsub where I see the Message class but no way to send a message.我还在https://firebase.google.com/docs/reference/functions#functions.pubsub上查看了云函数 sdk,在那里我看到了 Message 类,但无法发送消息。

Finally found it:终于找到了:

const messaging = admin.messaging();

which means that the documentation at https://firebase.google.com/docs/cloud-messaging/send-message?authuser=0 is outdated.这意味着https://firebase.google.com/docs/cloud-messaging/send-message?authuser=0上的文档已过时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Firebase Cloud Messaging 发送静默通知/后台通知? - how to send silent notification / background notification using Firebase Cloud Messaging? 未收到通过 iOS 应用程序中的 firebase 云功能发送的推送通知,尽管我从消息控制台获取 - Not receiving push notification sent via firebase cloud functions in iOS app though I get the from messaging console Firebase 通知 admin.messaging() 不是 function - Firebase 云消息传递 - Firebase notification admin.messaging() is not a function - Firebase cloud messaging 如何从节点服务器发送Firebase Cloud Messaging? - How to send Firebase Cloud Messaging from a node server? 如何收集用户 ID + 检索相应的令牌 + 通过 Firebase 云 Function (JS) 发送推送通知 - How do I Collect User IDs + Retrieve Corresponding Tokens + Send a Push Notification Via Firebase Cloud Function (JS) Firebase 云消息传递通知模型 - Firebase Cloud Messaging notification model 通过Node JS通过Firebase云消息发送有关主题的通知 - Send notification by firebase cloud messaging on a topic by node js Firebase 云 function 向 iPhone 发送通知 - Firebase cloud function send notification to iPhone Firebase Cloud功能发送通知错误 - Firebase Cloud Function Send Notification Error Firebase Cloud 功能消息传递一直发送通知,直到用户打开它 - Firebase Cloud function Messaging keep sending notification until user open it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM