'Get activate notification in flutter with FCM
I have a flutter social network app with firebase
I want to send notification to user when they get follow,like,comment or any activity
I know firebase cloud massaging do this but how
I want the exact code for this or some thing near with it
Solution 1:[1]
You can archive in 2 ways but in both ways you required user's fcm_token or device_token and firebase Server key.
Use this API - https://fcm.googleapis.com/fcm/send
to send push notifications to specific users.
- If you have own server
Manage via own server (secure & most preferred)
Crate your own API for send notifications to specific user. From your backend get that user's fcm-token & fire actual push API from your server.(firebase server key not save on mobile platform)
Do not include the server key anywhere in your client code. Also, make sure to use only server keys to authorize your app server.
- If you don't have own server.
You need to add firebase sever_key in front-end means app code. (Less preferable)
Just call actual firebase push API from your app code.
Note: in both ways you required receiver fcm_token or device_token. Because you need to pass firebase server_key & this token in that API.
Reference links
1.official latest documentation for API link1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |