Member-only story
Swift App states — The App Life Cycle
How are you going to respond to notifications if you don’t know the state your App is in?
We need to be aware of the execution states for Apps, because by definition a user can remove our App from the list of currently open Apps at any time!
Difficulty: Easy | Normal | Challenging
Prerequisites:
- Some understanding of how mobile Apps are used
Terminology
At any time an App is in one of 5 states
Not running: Could have just been installed!
Inactive: Open, but not receiving events, could be as it is transitioning to other states
Active: The normal mode of being in the foreground and recieving events
Background: Not visible but can execute code. This is useful when we are on the way to being suspended — so can send an API call (if you are lucky!)
Suspended: In the background but not executing code. Can be totally killed at any time (if there is low memory, for example).
Receiving events
You can receive events in some of the states, but not for others.