How can i show Push notification in Flutter app using Flask as server and my SQL as database, i wanna show notification in a flutter app when ever something new is added by admin in a specific table Thank you
I haven't try anything yet because I'm unable to find proper solution of it
CodePudding user response:
To show push notifications in a Flutter app using Flask as a server and MySQL as a database, you can follow these steps:
Set up a Flask server and connect it to your MySQL database. You can use the flask-mysql package to connect Flask to MySQL.
Implement a push notification service, such as Firebase Cloud Messaging (FCM), in your Flutter app. You can use the firebase_messaging package to integrate FCM in your Flutter app.
In your Flask server, set up a trigger or hook that listens for changes in the specific MySQL table you want to monitor. When a change is detected, send a push notification to the Flutter app using FCM.
In the Flutter app, register a listener for push notifications using the firebase_messaging package. When a push notification is received, display it using a notification library such as flutter_local_notifications.
CodePudding user response:
Here is a general outline of how you can implement push notifications in your Flutter app using Flask as the server and MySQL as the database:
- Set up a Flask server that connects to your MySQL database and listens for changes to a specific table. You can use a library like MySQL Connector to connect to the database and periodically check for updates to the table.
- When a new record is added to the table, the Flask server should send a push notification to the Flutter app. You can use a service like Firebase Cloud Messaging (FCM) to send the notification.
- In the Flutter app, set up FCM to receive push notifications. You can use the firebase_messaging package to set up FCM and handle incoming notifications.
- When the Flutter app receives a push notification, you can display it using a notification plugin like flutter_local_notifications.
This is just a high-level overview of the process, and there are many details that you will need to consider when implementing this in your own app. However, this should give you a good starting point for setting up push notifications in your Flutter app using Flask and MySQL.