【问题标题】:Automatically send notification to all the users whenever there is any change in firebase [closed]每当firebase发生任何变化时,自动向所有用户发送通知[关闭]
【发布时间】:2018-11-12 08:03:29
【问题描述】:

如何在 Firebase 中进行更改时通知所有用户?我不希望手动执行此操作。

【问题讨论】:

标签: database firebase firebase-realtime-database


【解决方案1】:

您应该使用由实时数据库触发器触发的 Firebase 云函数,请参阅文档 here。查看 Cloud Functions 的官方 Firebase 示例之一:

此示例演示了如何发送 Firebase 云消息 (FCM) 来自实时数据库触发函数的通知。样本 还具有用于体验 FCM 通知的 Web UI。

https://github.com/firebase/functions-samples/tree/master/fcm-notifications


如果您更喜欢发送电子邮件,请查看以下示例:

https://github.com/firebase/functions-samples/tree/master/email-confirmation

此示例“展示了如何向订阅/取消订阅时事通讯的用户发送确认电子邮件”。当用户在特定的实时数据库节点下写入一些数据时触发它。所以它和你的情况非常相似:当新数据写入给定的 DB 节点时,就会发送邮件。

您还可以调整它以使用 Sengrid,以及他们的 node.js 库https://github.com/sendgrid/sendgrid-nodejs。它运行良好,也是 Firebase 推荐的解决方案。

如果您在根据自己的案例调整其中一个示例时遇到困难,请随时分享您的代码并寻求帮助。

【讨论】:

    猜你喜欢
    • 2021-10-20
    • 1970-01-01
    • 1970-01-01
    • 2021-10-27
    • 1970-01-01
    • 2018-08-05
    • 2018-05-19
    • 1970-01-01
    • 2020-05-11
    相关资源
    最近更新 更多