Contents

Core Location

Obtain the geographic location and orientation of a device.

Overview

Core Location provides services that determine a device’s geographic location, altitude, and orientation, or its position relative to a nearby iBeacon device. The framework gathers data using all available components on the device, including the Wi-Fi, GPS, Bluetooth, magnetometer, barometer, and cellular hardware.

You use instances of the CLLocationManager class to configure, start, and stop the Core Location services. A location manager object supports the following location-related activities:

Standard and significant location updates

Track large or small changes in the user’s current location with a configurable degree of accuracy.

Region monitoring

Monitor distinct regions of interest and generate location events when the user enters or leaves those regions.

Beacon ranging

Detect and locate nearby beacons.

Compass headings

Report heading changes from the onboard compass.

To use location services, call liveUpdates(_:) to obtain an update stream, then asynchronously iterate over that stream to receive and process location updates, and receive diagnostic properties to understand if and why location updates don’t arrive.

If needed, the system prompts the user to grant or deny the request. An initial prompt is shown in the example below:

[Image]

On iOS devices, users can change location service settings at any time in the Settings app, affecting individual apps or the device as a whole. Your app receives events, including authorization changes, by observing asynchronous sequences from CLLocationUpdate and CLMonitor.

Topics

Essentials

Authorization

Monitoring

Location updates

Region monitoring

iBeacon

Compass headings

Geocoding

Location push service extension

Errors

Deprecated

Reference

Protocols