I have made a SOS application using Laravel.
Everything is working properly on the backend side.
And I have implemented the client side with Flutter
Now I want to send a message to the target audience with the API when the user clicks on the SOS button in the application.
I have done this, but I can’t do it in real time, I refresh the application with a timer.
How can I run it in real time?
- I have used the pusher service
- I don’t want to use firebase
thank you
2
Answers
this work for me
Yo, so many way to implement this feature, you can use:
1. Use websocket or socketio:
Laravel will implement socket feature (you can find the way to implement socket.io for laravel on Google).
Then, flutter app will connect to socket and receive the event to trigger actions, refer this library will help you: https://pub.dev/packages/socket_io_client
I think, if you fresh new with flutter, you can use push notification instead, because with websocket/socket.io, you need spend more time to handle connection handshake, process/convert data and many connection issue relates (SSL, testing no SSL, backend porting, protocol,…)
2. Use push notification:
Many services will help you like Firebase messaging, Onesignal push notifications,… but if you need to implement for Android, you should use Firebase messaging and android device should has PlayService (play store installed).
Backend:
Flutter:
2.1. Solution on Laravel:
2.2. Solution on Flutter:
Note: The push notification will also send notification to user, if you no need to display notification, just implement trigger only, use
data notification
.I will let you know the summary of implementation, the detail is too long and maybe not your choice, so if you need more detail, please comment, I will update.