我从云函数的官方文档中复制了这段代码:
exports.helloPubSub = functions.pubsub.topic('testTopic').onPublish(event => {
return console.log("test topic event data", event.data)
})
主题存在,功能部署成功;如果我向它发送消息,消息会到达设备,但不会调用此函数。
有人帮忙吗?
最佳答案
Firebase (Google) Cloud Messaging 和 Google Cloud Pub/Sub 是不同的消息系统,如 explained here :
Both are systems to deliver messages, but Google Cloud Messaging is used to deliver messages to and from end-user devices, while Google Cloud Pub/Sub is used to communicate between servers. Google Cloud Messaging is designed to scale to a very large number of delivery end points, but has low throughput (messages per second per channel). Pub/Sub does not have limits on throughput and has a more generic API.
虽然它们共享主题的概念,但发送到 FCM 主题的消息不会触发 Pub/Sub Cloud Function .
关于javascript - Firebase 的云功能 : functions. pubsub.topic ('testTopic' ).onPublish 未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44539765/