Instance Method


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


func requestAlwaysAuthorization()


When the current authorization status is CLAuthorizationStatus.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 CLAuthorizationStatus.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 CLAuthorizationStatus.authorizedWhenInUse, you may call this method one time to try and change your app's authorization status to CLAuthorizationStatus.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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software