You are writing an application whose main functionality is processing location changes using Core Location. You want the application to retrieve the iOS device location changes even if the application is sent to the background.
Select your project file in the Navigator of Xcode. Then, from the Capabilities section, switch on the Background Modes subsection. After the list of background modes is given to you, tick on the Location switch.
When your application is running in the foreground, you can
receive delegate messages from an instance of
CLLocationManager telling you when iOS detects
that the device is at a new location. However, if your application is
sent to the background and is no longer active, the location delegate
messages will not be delivered normally to your application. They will
instead be delivered in a batch when your application again becomes the
If you still want to be able to receive changes in the location of the user’s device while running in the background, you must enable the Location updates capability of your app, as described in the Solution section of this recipe. Once in the background, your application will continue to receive the changes in the device’s location. Let’s test this in a simple app with just the app delegate.
What I intend to do in this app is to keep a Boolean value in the
app delegate, called
executingInBackground. When the app goes to the ...