I am trying to send push notification from SQL server to real device. Is it possible to make this function without firebase? I want to do this with my API from server with url, not with firebase. How can I do this? thanks for help and advice.
CodePudding user response:
Yes its possible
You have to use Firebase cloud messaging FCM Firebase Cloud Messaging What does it do, Create a Firebase project and connect it to your flutter app. In the app get the FCM token of that device and save it somewhere in the backend MySQL database, or any other database, when ever you want to send a notification to a specific device, you grab the FCM token from the database of cource each Fcm token you have already associate it with the user id, so after saving the fcm token in the database, next step you grab the device FCM token of the user you want to notify, you can grab one FCM token or as many as you want and loop through them and send a notification to the device by calling the Firebase project using CURL for example with PHP
curl -X POST --header "Authorization: key=<API_ACCESS_KEY>" \
--Header "Content-Type: application/json" \
https://fcm.googleapis.com/fcm/send \
-d "{\"to\":\"<YOUR_DEVICE_ID_TOKEN>\",\"notification\":{\"title\":\"Hello\",\"body\":\"Yellow\"}}"
see this answer How can I send a Firebase Cloud Messaging notification