Home > database >  How to send data from background service to main application in flutter
How to send data from background service to main application in flutter

Time:03-23

I am running a background servie and at a specific time, I want to send some data in form of JSON string to my application. It may happen that my app is currently terminated, so I am using app laucher plugin to open my application. After opening the application, I want to send some data to application so as to display it. So, how can I send the message and recieve it in my main application (I will have to change the state of my widget once I recieve the data)?

CodePudding user response:

I am not completely sure if this works, but I think instead of somehow sending the data from the background service to the main application you could probably save it in shared preferences or local database or using hive or something similar and simply retrieve it in your main application.

CodePudding user response:

Definitely agree with above answer , But if you want to secure your application more then you can use Flutter_Secure_Storage. It is alternative to Shared_Preference :)

  • Related