How to make service in flutter [closed]

I had the same problem to solve in one of my projects. Unfortunately, Flutter does not provide any way to implement always-on service. Moreover, iOS does not allow anything like this unless you are running some predefined services like Music Player.

So we can implement this natively as follows(with some limitations on iOS):

Android:

I implemented Foreground Service in Android. https://developer.android.com/guide/components/services#StartingAService

Then, I used MethodChannels to start and stop the service from Flutter. https://flutter.dev/docs/development/platform-integration/platform-channels

iOS:

Only specific background tasks are allowed on iOS. Check below:

enter image description here

More here: https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/updating_your_app_with_background_app_refresh

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top