I want to check if the app is running in the background.
In:
locationManagerDidUpdateLocation {
if(app is runing in background){
do this
}
}
I want to check if the app is running in the background.
In:
locationManagerDidUpdateLocation {
if(app is runing in background){
do this
}
}
A Swift 4.0 extension to make accessing it a bit easier:
To access from within your app:
If you are looking for information on the various states (
active
,inactive
andbackground
), you can find the Apple documentation here.swift 4
If you prefer to receive callbacks instead of "ask" about the application state, use these two methods in your
AppDelegate
:App delegate gets callbacks indicating state transitions. You can track it based on that.
Also the applicationState property in UIApplication returns the current state.
Swift 3
Swift version :