Reputation: 399
I'm creating a messaging app on flutter and it's using cloud Firestore to receive and store messages. Everything is working fine but I want to add the notifications feature (when X sends a message to Y, Y gets a notification).
I've researched this quite a lot and I didn't find any tutorials for it. All I find are tutorials for FCM that broadcasts notifications.
The only concept I understand now(but I also don't know how to implement) is to implement a Firestore trigger when the database is updated to execute a cloud function (onUpdate) that sends a notification to the receiving end.
And for that concept, I also didn't find any documentation for it in flutter or dart. I've used the cloud_functions package from pub.dev and the documentation is only for nodeJS.
Any idea on how to implement this concept? and if it's wrong for a messaging app, I'd appreciate any other better solution.
Upvotes: 4
Views: 6310
Reputation: 5608
There are two things you need to work on. First, on server side, you will create a Cloud function that pushes notifications when there is a change on your database. Second, on client side, you will implement the firebase_messaging
package in order to receive notifications.
Check this for setting cloud function and this for firebase_messaging
.
Upvotes: 1
Reputation: 987
I know it's a little late but anyone who wants to know, you need to use Firebase trigger, you can follow the below article.
flutter-chat-app-extended-push-notification-messages
Upvotes: 1