I found two possible approaches to deliver notifications after some changes in the Firebase real time database (for example in a chat application):
It is possible to use Cloud Functions for Firebase as explained in this blog post.
I have also found here another simpler approach using just an android service that listens for changes in the database.
I would like to know what are the pros and the cons of the two approaches before trying to implement one of them and since the second one seems much simpler than the first one.
This includes downstream messages from servers to client apps, and upstream messages from client apps to servers. Firebase is a cloud service designed to power real-time, collaborative applications.
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 can use both Firebase Realtime Database and Cloud Firestore in your app, and leverage each database solution's benefits to fit your needs. For example, you might want to leverage Realtime Database's support for presence, as outlined in Build Presence in Cloud Firestore.
Instead of typical HTTP requests, the Firebase Realtime Database uses data synchronization—every time data changes, any connected device receives that update within milliseconds. Provide collaborative and immersive experiences without thinking about networking code.
The android service
solution described in https://www.codementor.io/sundayakinsete/firebase-real-time-notifications-app-to-app-opkwbo6ba has serious limitations:
on the other side, if you use Firebase Cloud Messaging (via Cloud Functions or a custom server):
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