How do I notify all users when a change is made in firebase? I do not wish to do this manually.
-
See https://stackoverflow.com/questions/44145208/firebase-send-notification-upon-changes-in-real-time-database, https://stackoverflow.com/questions/38022413/firebase-notification-on-child-added-modified, https://stackoverflow.com/questions/47406899/send-notification-when-new-child-is-added-to-firebase-database, and probably a few more. If you're having trouble making those work, post a question that shows what you've tried and where you got stuck. – Frank van Puffelen Jun 02 '18 at 15:07
-
Possible duplicate of [Firebase send notification upon changes in real time database](https://stackoverflow.com/questions/44145208/firebase-send-notification-upon-changes-in-real-time-database) – Makyen Feb 08 '19 at 23:02
1 Answers
You should use a Firebase Cloud Function tiggered by a Realtime Database trigger, see doc here. Have a look at one of the official Firebase samples for Cloud Functions:
This sample demonstrates how to send a Firebase Cloud Messaging (FCM) notification from a Realtime Database triggered Function. The sample also features a Web UI to experience the FCM notification.
https://github.com/firebase/functions-samples/tree/master/fcm-notifications
If you prefer to send an email, look at the following sample:
https://github.com/firebase/functions-samples/tree/master/email-confirmation
This samples "shows how to send a confirmation emails to users who are subscribing/un-subscribing to a newsletter". It is triggered when a user write some data under as specific Real Time Database node. So it is very similar to your case: when new data is written under a given DB node, the mail is sent.
You can also adapt it in order to use Sengrid, with their library for node.js https://github.com/sendgrid/sendgrid-nodejs. It works very well and is also a recommended solution by Firebase.
In case you encounter difficulties when adapting one of these samples to your case, do not hesitate to share your code and ask for help.

- 79,263
- 10
- 95
- 121