How do I notify all users when a change is made in firebase? I do not wish to do this manually.
Firebase Cloud Messaging (FCM) provides a reliable and battery-efficient connection between your server and devices that allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With