Home > Back-end >  I want to be notified when data is added in Firebase Realtime Database
I want to be notified when data is added in Firebase Realtime Database

Time:10-21

I have an application with two different package names. There are separate databases for these two applications. If a user adds new data, I want to receive a message. I don't want to constantly check. How can I do that?

I can receive notifications as Mail, or I can make a different application and an application that controls the content of these two applications. But I don't know how to make notifications.

CodePudding user response:

To display notification to a user about a change in the data while they are not actively using the app, you'll typically use Firebase Cloud Message or some other out-of-band mechanism to deliver the message.

To detect the relevant data change and send that message, you'll want to run code in a trusted environment that is guaranteed to continue to run all the time. An example of such an environment is Cloud Functions, which also has an example of notifying the user when something interesting happens.

CodePudding user response:

You can use cloud functions to trigger events when there are document changes.

Docs are here : https://firebase.google.com/docs/functions/firestore-events.

Then you can tie those triggers with FCM to get notified when doc changes.

  • Related