Flutter workmanager schedule background work on iOS

1.8k Views Asked by At

I would like to run dart code a few times a day regardless of whether the app is open or terminated. I have looked into workmanager library and I have a couple things that I don't understand about iOS. The library says "This plugin allows you to schedule background work on Android and iOS." But in the iOS Setup it says "Periodic tasks are available on Android only for now!". What does this mean? Is the iOS limited for running a single background task after user has closed the application? What are the libraries limitations when user has closed (terminated) app on iOS device?

1

There are 1 best solutions below

0
On

Workmanager only supports one-off tasks on iOS. It is pretty clear on that in its documentation.

Moreover, don't expect your tasks to execute when the app is terminated from the app switcher.

iOS decides when to assign threads for your process based on things such as battery life, if the device is awake or not, and now even has ML models that learn from the past performance of your app and your usage patterns. You can't reliably predict when your task gets picked from the queue.

In my case, I had some computation to do at certain times in the day and send a notification. I just moved all of that computation to the server and sent remote notifications.