fluttercommunity / flutter_workmanager

A Flutter plugin which allows you to execute code in the background on Android and iOS.
862 stars 277 forks source link

feat: Long-running workers on Android devices #573

Open wagner1343 opened 1 month ago

wagner1343 commented 1 month ago

This pull request introduces foreground service support on Android devices as per Android workmanager docs Support for long-running workers.

Foreground service support:

Code refactoring and improvements:

These changes allows tasks to run as foreground services.

This PR addresses issue https://github.com/fluttercommunity/flutter_workmanager/issues/236, but goes against the recomendation on https://github.com/fluttercommunity/flutter_workmanager/pull/511 of using Workmanager.registerProcessingTask to implement long-running wokers on android. Since the implementation of long-running workers on Android tightly depends on specific requirements such as handling notifications and activating a foreground service on the run, a decision was made to create a dedicated API which laverages ListenableWorker.serForegroundAsync and minimally handles notification management in order to implement long-running workers while following android guidelines.

docs-page[bot] commented 1 month ago

To view this pull requests documentation preview, visit the following URL:

docs.page/fluttercommunity/flutter_workmanager~573

Documentation is deployed and generated using docs.page.

wagner1343 commented 1 month ago

@ened I Kindly ask for your input on this.