Instance Method

requestAlwaysAuthorization()

Requests permission to use location services whenever the app is running.

Declaration

func requestAlwaysAuthorization()

Discussion

When the current authorization status is notDetermined, this method runs asynchronously and prompts the user to grant permission to the app to use location services. The user prompt contains the text from the NSLocationAlwaysUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method. After the status is determined, the location manager delivers the results to the delegate’s locationManager(_:didChangeAuthorization:) method. If the current authorization status is anything other than notDetermined, this method does nothing and does not call the locationManager(_:didChangeAuthorization:) method, with one exception. If your app has never requested always authorization and its current authorization status is authorizedWhenInUse, you may call this method one time to try and change your app's authorization status to authorizedAlways.

You must call this method or the requestWhenInUseAuthorization() method prior to using location services. When the user grants “Always” authorization to your app, your app can start any of the available location services while your app is running in the foreground or background. In addition, services that allow your app to be launched in the background continue to do so.

For more information about the NSLocationAlwaysUsageDescription key, see Information Property List Key Reference.

See Also

Requesting Authorization for Location Services

func requestWhenInUseAuthorization()

Requests permission to use location services while the app is in the foreground.

enum CLAuthorizationStatus

Constants indicating whether the app is authorized to use location services.