Is it possible to generate a push notification (if the app is not in the foreground) on firebase db changes? I started coding an android app.
To receive messages & notifications a real device is required. As mentioned in the Usage documentation, message payloads can include a notification property which the Firebase SDKs intercept and attempt to display a visible notification to users.
If your own application is in the foreground, the Firebase Android SDK will block displaying any FCM notification no matter what Notification Channel has been set. We can however still handle an incoming notification message via the onMessage stream and create a custom local notification using flutter_local_notifications:
Asynchronous listeners: Data stored in a Firebase Realtime Database is retrieved by attaching an asynchronous listener to a database reference. The listener is triggered once for the initial state of the data and again anytime the data changes. An event listener may receive several different types of events.
With the repo cloned, you can modify any or all of the Firebase In-App Messaging message types: Card, Modal, Banner, and ImageOnly. Each type corresponds to a message layout in the Firebase In-App Messaging campaign creation flow.
Firebase provides a tool called Cloud Functions.
With this, you can listen to your Firebase Database and send Notifications without the need for an external server :)
See : https://firebase.google.com/docs/functions/use-cases
To do it in a simple way, you can use a Service, in this Service you can set a Listener on a ref in your firebase DB when the event is triggered you can create a notify and show it to the user.
This is a very simple tutorial: https://www.simplifiedcoding.net/android-push-notification-tutorial-using-firebase/
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