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.

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

Related Symbols

class func authorizationStatus()

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

func requestWhenInUseAuthorization()

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