Firebase Messaging in Flutter Upstream messages - firebase

I'm trying to configure Firebase Messaging in Flutter, but it seems that there is no implementation yet for the Upstream messages.
https://firebase.google.com/docs/cloud-messaging/android/upstream
What I want to do is to add a reminder and notify the user after x time with a push notification.
Let me know if you guys have any other solution, or we should simply wait for Flutter and Firebase for Flutter to became stable.
Thanks
Alvin

You are correct that there is no implementation for upstream messaging in FlutterFire yet, we are working on filling out these features. However given your use case you may be able to do something like write the user's reminder to Firestore or Firebase Realtime Database then when you are ready to send push notifications you can use Cloud Functions for Firebase to send the messages to the required devices.

Related

Flutter Notifications with Firebase Realtime Database

I have a Flutter app integrated with a Firebase Realtime Database.
I want a notification (actually an alarm kind of thing if possible), when an item (lets call it alarm) in the database is set to "true". I always see firebase_messaging plugin for notifications, but I am not sure if I'm supposed to use this plugin despite that my app doesn't have anything to do with messaging.
I am totally new to both Flutter and Firebase, can you tell me how to listen to the database even if the app is not running?
By the way, I am currently building the app for only Android, but I want to build it for IOS too in the future.
Thanks.
You can use/write firebase cloud fucntion. Using firebase cloud function you can watch any document/field and try to write trigger logic like if a field is set to true then this cloud function will throw an notification via firebase messaging.
https://firebase.flutter.dev/docs/functions/overview/
When the user is not actively using the app there is no reliable way to continue to listen to changes in the Firebase Realtime Database. To notify the user of changes to the database in that situation, you'll need to listen for those change on an environment that is always on, and then send a message to the user through Firebase Cloud Messaging.
One environment that is always in is Cloud Functions, which is also part of Firebase, and allows you to run small snippets of JavaScript code on Google's servers in response to things that happen in your Firebase project. The documentation of Cloud Functions for Firebase as example of how to notify the user when something interesting happens in the database:
Developers can use Cloud Functions to keep users engaged and up to date with relevant information about an app. Consider, for example, an app that allows users to follow one another's activities in the app. Each time a user adds themselves as a follower of another user, a write occurs in the Realtime Database. Then this write event could trigger a function to create Firebase Cloud Messaging (FCM) notifications to let the appropriate users know that they have gained new followers.
The function triggers on writes to the Realtime Database path where followers are stored.
The function composes a message to send via FCM.
FCM sends the notification message to the user's device.
To review working code, see Send FCM notifications.

Flutter - How to integrate automatic push notifications

I have already built a chat app to practice flutter and I would really like to integrate push notifications that notify the users when a new message is sent but I don't seem to find any relevant information on the internet about this topic, I am currently using firebase. what can I do in order to achieve this functionality?
Since you are already using firebase, look into Firebase Cloud Messaging. You'll need to
Save each user's device tokens in Cloud Firestore and Realtime Database
When a message is sent/written to the database, trigger a cloud function to send a notification through Cloud Messaging.
you have to use firebase cloud messaging by you have to safe each user token id
that will be notify users for a particular event
check my repository in developer branch where I implement push notification by
using firebase cloud messaging
my repository for push notification

Do any features of Firebase Cloud messaging require a Firebase database?

I'm thinking about implementing Firebase Cloud Messaging without implementing a firebase database and it's unclear to me which features of FCM are supported without having a firebase database.
For instance, getting message delivery statistics (https://firebase.google.com/docs/cloud-messaging/understand-delivery) and sending notifications via the firebase console (https://firebase.google.com/docs/cloud-messaging/js/send-with-console). It doesn't explicitly say whether you need a firebase database in either of documents but I'd like to clear about that before implementing it.
So my question is, do you need a firebase database to send notifications via the firebase console or to view message delivery statistics? I know for the latter you need to implement google analytics. And also as a bonus, are there any firebase features that depend on having a firebase database?
Thank you
All FCM features are supported without having to use Realtime Database. They are completely separate products, and are only related as much as you want them to be in your app.

Flutter FCM Push Notification Delivery Status

I wonder if there is a way I could track fcm push notifications delivery in flutter so I can set a callback and be notified when notification is received by device?
Please upload a bit of your code/ detailed code flow as to how you are achieving push notifications .i.e, from webserver/cloud functions/flutter package. In any of the methods, you receive information on the about failed/delivered msgs as well a Message-ID used as a reference when looking up particular messaging operation
If you rely on a web server, then in order to set callbacks on your web server, you can use the feature of Firebase Cloud messaging Data export to BigQuery and apply cloud functions to listen to the undelivered messages in bulk automatically. This however may turn a bit costly on a larger scale.

Firebase Cloud Messages Push Notifications

I have developed a simple android app using Firebase database to store stuff.
Now, I want to set up notifications for each time a button is clicked.
Each time the button is clicked, it will take some info from firebase (text mostly) and will send a notification to anyone who downloaded the app.
I understood that simply creating a notificationManager won't work as needed.
I also heard about Firebase Cloud Messaging but im pretty new to this so I must know what I should start learning to make that work out.
So, if you have any good tutorials or anything helpful, that would be great!
Thanks!
You need to receive for the FCM in android app. Refer this doc. And you need to can use database triggers in firebase cloud functions to send FCM notification, or you need to deploy a cloud http function to do so.

Resources