|
| 1 | +# workmanager_ios |
| 2 | + |
| 3 | +[](https://pub.dartlang.org/packages/workmanager_ios) |
| 4 | + |
| 5 | +The iOS implementation of [`workmanager`][workmanager]. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +This package is [endorsed][federated_plugin_docs], which means you can simply use `workmanager` |
| 10 | +normally. This package will be automatically included in your app when you do, |
| 11 | +so you do not need to add it to your `pubspec.yaml`. |
| 12 | + |
| 13 | +However, if you `import` this plugin directly (instead of the generic `workmanager` plugin), |
| 14 | +you should add it to your `pubspec.yaml`: |
| 15 | + |
| 16 | +```yaml |
| 17 | +dependencies: |
| 18 | + workmanager_ios: ^0.8.0 |
| 19 | +``` |
| 20 | +
|
| 21 | +## iOS setup |
| 22 | +
|
| 23 | +For iOS background processing, you need to configure your app properly. |
| 24 | +For detailed setup instructions, see the [iOS setup documentation][ios_setup]. |
| 25 | +
|
| 26 | +## Features |
| 27 | +
|
| 28 | +This iOS implementation supports: |
| 29 | +
|
| 30 | +- **One-off tasks**: Execute background tasks once using BGTaskScheduler (iOS 13+) |
| 31 | +- **Periodic tasks**: Execute background tasks using BGAppRefreshTask (iOS 13+) or Background Fetch |
| 32 | +- **Processing tasks**: Execute long-running background tasks using BGProcessingTask (iOS 13+) |
| 33 | +- **Task cancellation**: Cancel individual tasks or all tasks |
| 34 | +- **Task constraints**: Network and charging requirements (iOS 13+) |
| 35 | +- **Task scheduling info**: Print information about scheduled tasks (iOS 13+) |
| 36 | +
|
| 37 | +## Limitations |
| 38 | +
|
| 39 | +- **iOS 13+ required**: BGTaskScheduler features require iOS 13 or later |
| 40 | +- **Tags not supported**: `cancelByTag` operations are not available on iOS |
| 41 | +- **No scheduling status**: `isScheduledByUniqueName` is not supported on iOS |
| 42 | +- **Background execution limits**: iOS strictly limits background execution time and frequency |
| 43 | +- **System scheduling**: iOS determines when tasks actually run based on user behavior and system resources |
| 44 | + |
| 45 | +## Background execution on iOS |
| 46 | + |
| 47 | +Please note that iOS has strict limitations on background execution: |
| 48 | + |
| 49 | +- Background tasks are scheduled by the system and may not run immediately |
| 50 | +- The system considers user behavior patterns when scheduling background work |
| 51 | +- Tasks may be throttled or denied if the app is used infrequently |
| 52 | +- Background App Refresh must be enabled by the user for your app |
| 53 | + |
| 54 | +For more information, see Apple's [Background Tasks documentation][apple_background_tasks]. |
| 55 | + |
| 56 | +[workmanager]: https://pub.dartlang.org/packages/workmanager |
| 57 | +[federated_plugin_docs]: https://flutter.dev/go/federated-plugins |
| 58 | +[ios_setup]: https://github.com/fluttercommunity/flutter_workmanager/blob/main/IOS_SETUP.md |
| 59 | +[apple_background_tasks]: https://developer.apple.com/documentation/backgroundtasks |
0 commit comments