I need to listen for update on the client side whenever something in the Firestore database changes. I need some clarification about this topic:
Let's say that we want to notify the user whenever a new document is created in a collection: We have 2 cases:
- when the user is on the app
- when the user is out of the app
for the second point I can create a cloud function firestore trigger that notifies the user through the push notification service
But on the first point I don't know which is the best approach.
(maybe setting up a snapshotListener? but how can I do that on the global scope of the app? Is it the right approach?)