如何在 Firebase 函数中拥有多个 Firebase 数据库侦听器和 `exports.pushNotification`
How can I have multiple Firebase Database listeners and `exports.pushNotification` in Firebase Functions
我有一个监听器,当 Firebase 实时数据库发生变化时推送通知。
exports.pushNotification = functions.database
.ref("/Currency/Price")
.onWrite((change, context) => { ... }
我尝试只复制上面显示的相同函数并更改数据库引用,但它最终忽略了第一个,所以只有第二个数据库引用推送通知,而不是第一个。
如何为实时数据库中的另一条记录添加另一个侦听器和推送通知?
如果要声明两个不同的 Cloud Functions 应该在同一个数据库位置(即节点)触发,只需使用另一个名称,如下所示:
exports.pushNotification1 = functions.database
.ref("/Currency/Price")
.onWrite((change, context) => { ... }
exports.pushNotification2 = functions.database
.ref("/Currency/Price")
.onWrite((change, context) => { ... }
如果你想在另一个位置声明另一个函数,只需按如下操作:
exports.pushNotification1 = functions.database
.ref("/Currency/Price")
.onWrite((change, context) => { ... }
exports.pushNotification2 = functions.database
.ref("/abcd/efgh")
.onWrite((change, context) => { ... }
我有一个监听器,当 Firebase 实时数据库发生变化时推送通知。
exports.pushNotification = functions.database
.ref("/Currency/Price")
.onWrite((change, context) => { ... }
我尝试只复制上面显示的相同函数并更改数据库引用,但它最终忽略了第一个,所以只有第二个数据库引用推送通知,而不是第一个。
如何为实时数据库中的另一条记录添加另一个侦听器和推送通知?
如果要声明两个不同的 Cloud Functions 应该在同一个数据库位置(即节点)触发,只需使用另一个名称,如下所示:
exports.pushNotification1 = functions.database
.ref("/Currency/Price")
.onWrite((change, context) => { ... }
exports.pushNotification2 = functions.database
.ref("/Currency/Price")
.onWrite((change, context) => { ... }
如果你想在另一个位置声明另一个函数,只需按如下操作:
exports.pushNotification1 = functions.database
.ref("/Currency/Price")
.onWrite((change, context) => { ... }
exports.pushNotification2 = functions.database
.ref("/abcd/efgh")
.onWrite((change, context) => { ... }