Article

Choosing the Authorization Level for Location Services

Choose the appropriate level of access to location data for your app.

Overview

The type of authorization (“when-in-use” or “always”) that you request determines which location services your app can access and when it can use them:

  • When-in-use authorization. Your app can use most services but cannot use services that automatically relaunch the app. Your app must always start services while running in the foreground. If you enable the background location capability for your app, a suspended app will be woken in the background to handle location events. However, if your app is not running, it will not be launched.

  • Always authorization. Your app can use all location services, and it can start those services from either the foreground or the background. If a location-related event occurs when your app is not running, the system launches your app and delivers the event.

It is recommended that you request only when-in-use authorization whenever possible. If your app requests and receives when-in-use authorization, you can make a separate request for always authorization later. (Apps may make only one request for always authorization.) Even if you request always authorization, the user has the option of granting your app when-in-use authorization instead. So you must always be prepared to run with when-in-use authorization.

Table 1 lists the location services available for each type of authorization.

Table 1

Authorizations supported by the location services

Service

When-in-use

Always

Standard location service

Supported

Supported

Significant-change location service

Not available

Supported

Visits service

Not available

Supported

Region monitoring

Not available

Supported

iBeacon ranging

Supported

Supported

Heading service

Supported

Supported

Geocoding services

Supported

Supported

After making an authorization request, it is safe to start location services before your request is resolved. However, location services do not deliver any data until the authorization status changes to authorizedAlways or authorizedWhenInUse. Implement the locationManager(_:didChangeAuthorization:) method in your location manager delegate to be notified when your app's authorization status changes.

Topics

Requesting Authorization

Requesting When-In-Use Authorization

Request authorization to use location services only when your app is running.

Request Always Authorization

Request authorization to use location services at any time.

See Also

First Steps

Determining the Availability of Location Services

Determine which location services are active and available on the user's device.

class CLLocationManager

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

protocol CLLocationManagerDelegate

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