Obtain the geographic location and orientation of a device.
- iOS 2.0+
- macOS 10.6+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
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
CLLocation 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, your app requests authorization and the system prompts the user to grant or deny the request. An initial prompt is shown in Figure 1.
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, in your location manager's delegate object, which conforms to the