Member-only story
iOS Application States
UIApplication State Transitions and Background Rules
Most common use case is when the user taps the app icon and the application starts.
1.) App wakes up
2.) You do some initialisation (Optional, but almost always used)
3.) Create some UI, Screen
4.) Trigger some API calls (Optional, but often used)

While this is happening, app state (UIApplication.State
) is changing.
Inactive
The app is running in the foreground but is not receiving events. Transitional state (multitasking UI). The app is either going to or coming from Active state. Like open another app, home button tap, screen turned off by power button, terminate the app by swipe, caller…
Transitions:
1.) Not Running -> Inactive -> Active
2.) Active -> Inactive -> Background
3.) Background -> Inactive -> Active
Active
The app is running in the foreground and currently receiving events. The app is onscreen and running and ready for user interaction.
Background
The app is running in the background.
Can be launched by the system by Push / Local Notification, Time Sensitive Events, Background Processing, Background Fetching…
Can perform some logic. In this state after some time the OS kills the app.
On iOS12 it is around 180s (not officially confirmed by Apple).
On other OS versions it is mostly around 10s in my experience.
It can be extended by beginBackgroundTask(expirationHandler:)
or beginBackgroundTask(withName:expirationHandler:)
.
If you want to know exactly the time, UIApplication.shared.backgroundTimeRemaining
can show it.
Keep in mind that with the break point it will still be ticking as this is OS specified time. Also if you see some huge number that means it is “infinite” and termination is not triggered.