The system resumes (or relaunches) your app in the background because the user enters your region. You schedule a timer for 3 minutes and start a background task to prevent the app from being suspended. After 30 seconds the background task expires.
- How long iOS apps can run in background?
- How do I limit background processes on my iPhone?
- How do I keep my iPhone apps running in the background fully operational?
- What is the current recommended way to handle long running background tasks?
How long iOS apps can run in background?
For most apps, five seconds is enough to perform any crucial tasks, but if you need more time, you can ask UIKit to extend your app's runtime. You extend your app's runtime by calling the beginBackgroundTask(withName:expirationHandler:) method. Calling this method gives you extra time to perform important tasks.
How do I limit background processes on my iPhone?
Go to iPhone Settings and tap General. Select Background App Refresh and choose which apps you want to restrict background data on by toggling the switch from green to gray.
How do I keep my iPhone apps running in the background fully operational?
For iOS Devices
If Background refresh is greyed out in the ON position, go To Settings App - > General - > Background App Refresh - > Turn on the option for the system, and then you can turn on / off by app.
What is the current recommended way to handle long running background tasks?
Recommended solution
Scheduling deferred work through WorkManager is the best way to handle tasks that don't need to run immediately but which ought to remain scheduled when the app closes or the device restarts.