I want to send a notification from Firebase to a specific Flutter mobile device.
The logic (in pseudocode) would look like this:
Firebase function onSomethingHappening (interestedCientId){
writeToFirestore // this part is easy
notifyClientDevice (interestedCientId)
}
I know Firebase has Messaging ability, but it seems to broadcast the message to all devices.
Is there a way through Messaging (or any other Firebase means) to send a message to a specific device?
2
Answers
Yes, have a look at the "Send messages to specific devices" section in the Firebase Cloud Messaging documentation.
to send push notification to a specific device your have to get the FCM token from devices ad save that Token somewhere in the server or in firebase realtime or firestore. then you can send notification based on the that token to that specific device.
Please read the following documentations:
https://firebase.flutter.dev/docs/messaging/notifications/
https://firebase.google.com/docs/cloud-messaging/flutter/client
Here is the simple code
with this token you can send notification form firebase console or the this API
METHOD FOR THIS IS POST