Class

CLLocationManager

The object that you use to start and stop the delivery of location-related events to your app.

Declaration

@interface CLLocationManager : NSObject

Overview

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

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

  • Reporting heading changes from the onboard compass.

  • Monitoring distinct regions of interest and generating location events when the user enters or leaves those regions.

  • Reporting the range to nearby beacons.

Assign a custom object to the delegate property, conforming to the CLLocationManagerDelegate protocol. Assign the delegate before starting any location services. The system calls the delegate's locationManager:didChangeAuthorizationStatus: method immediately when the location manager is created. All location and heading-related updates and events are delivered to that delegate.

See Adding Location Services to Your App for more information.

Topics

Determining the Availability of Services

+ significantLocationChangeMonitoringAvailable

Returns a Boolean value indicating whether the significant-change location service is available on the device.

+ headingAvailable

Returns a Boolean value indicating whether the location manager is able to generate heading-related events.

+ isMonitoringAvailableForClass:

Returns a Boolean value indicating whether the device supports region monitoring using the specified class.

+ isRangingAvailable

Returns a Boolean value indicating whether the device supports ranging of beacons that use the iBeacon protocol.

+ locationServicesEnabled

Returns a Boolean value indicating whether location services are enabled on the device.

Receiving Data from Location Services

delegate

The delegate object to receive update events.

CLLocationManagerDelegate

The methods that you use to receive events from an associated location manager object.

Requesting Authorization for Location Services

- requestWhenInUseAuthorization

Requests the user’s permission to use location services while the app is in use.

- requestAlwaysAuthorization

Requests the user’s permission for location services whether or not the app is in use.

CLAuthorizationStatus

Constants indicating the app's authorization to use location services.

+ authorizationStatus

Returns the app’s authorization status for using location services.

Initiating Standard Location Updates

- startUpdatingLocation

Starts the generation of updates that report the user’s current location.

- stopUpdatingLocation

Stops the generation of location updates.

- requestLocation

Requests the one-time delivery of the user’s current location.

pausesLocationUpdatesAutomatically

A Boolean value indicating whether the location manager object may pause location updates.

allowsBackgroundLocationUpdates

A Boolean value indicating whether the app should receive location updates when suspended.

showsBackgroundLocationIndicator

A Boolean indicating whether the status bar changes its appearance when an app uses location services in the background.

distanceFilter

The minimum distance (measured in meters) a device must move horizontally before an update event is generated.

CLLocationDistanceMax

A constant indicating the maximum distance.

kCLDistanceFilterNone

A constant indicating that all movement should be reported.

desiredAccuracy

The accuracy of the location data.

activityType

The type of user activity associated with the location updates.

CLActivityType

Constants indicating the type of activity associated with location updates.

Initiating Significant Location Updates

- startMonitoringSignificantLocationChanges

Starts the generation of updates based on significant location changes.

- stopMonitoringSignificantLocationChanges

Stops the delivery of location events based on significant location changes.

Initiating Heading Updates

- startUpdatingHeading

Starts the generation of updates that report the user’s current heading.

- stopUpdatingHeading

Stops the generation of heading updates.

- dismissHeadingCalibrationDisplay

Dismisses the heading calibration view from the screen immediately.

headingFilter

The minimum angular change (measured in degrees) required to generate new heading events.

kCLHeadingFilterNone

A constant indicating that all header values should be reported.

headingOrientation

The device orientation to use when computing heading values.

CLDeviceOrientation

Constants indicating the physical orientation of the device.

Initiating Region Monitoring

- startMonitoringForRegion:

Starts monitoring the specified region.

- stopMonitoringForRegion:

Stops monitoring the specified region.

monitoredRegions

The set of shared regions monitored by all location manager objects.

maximumRegionMonitoringDistance

The largest boundary distance that can be assigned to a region.

Initiating Beacon Ranging Requests

- requestStateForRegion:

Retrieves the state of a region asynchronously.

- startRangingBeaconsSatisfyingConstraint:

Starts the delivery of notifications for the specified beacon constraints.

- stopRangingBeaconsSatisfyingConstraint:

Stops the delivery of notifications for the specified beacon constraints.

rangedBeaconConstraints

The set of beacon constraints currently being tracked using ranging.

- startRangingBeaconsInRegion:

Starts the delivery of notifications for the specified beacon region.

Deprecated
- stopRangingBeaconsInRegion:

Stops the delivery of notifications for the specified beacon region.

Deprecated
rangedRegions

The set of regions currently being tracked using ranging.

Deprecated

Initiating Visit Event Updates

- startMonitoringVisits

Starts the delivery of visit-related events.

- stopMonitoringVisits

Stops the delivery of visit-related events.

Getting Recently Retrieved Data

location

The most recently retrieved user location.

heading

The most recently reported heading.

Deferring Location Updates

+ deferredLocationUpdatesAvailable

Returns a Boolean value indicating whether the device supports deferred location updates.

Deprecated
- allowDeferredLocationUpdatesUntilTraveled:timeout:

Asks the location manager to defer the delivery of location updates until the specified criteria are met.

Deprecated
- disallowDeferredLocationUpdates

Cancels the deferral of location updates for this app.

Deprecated
CLTimeIntervalMax

A value representing an unlimited amount of time.

Related Types

CLLocationDegrees

A latitude or longitude value specified in degrees.

CLLocationDistance

A distance measurement (measured in meters) from an existing location.

CLLocationAccuracy

The accuracy of a geographical coordinate.

Deprecated

locationServicesEnabled

A Boolean value indicating whether location services are enabled on the device.

Deprecated
headingAvailable

A Boolean value indicating whether the location manager is able to generate heading-related events.

Deprecated
purpose

An app-provided string that describes the reason for using location services.

+ regionMonitoringAvailable

Returns a Boolean value indicating whether region monitoring is supported on the current device.

Deprecated
+ regionMonitoringEnabled

Returns a Boolean value indicating whether region monitoring is currently enabled.

Deprecated
- startMonitoringForRegion:desiredAccuracy:

Starts monitoring the specified region for boundary crossings.

Deprecated

Relationships

Inherits From

See Also

Essentials

Adding Location Services to Your App

Implement features that can access information about a user’s location.

CLLocationManagerDelegate

The methods that you use to receive events from an associated location manager object.