Requests permission to use location services while the app is in the foreground.
- iOS 8.0+
- tvOS 9.0+
- watchOS 2.0+
- Core Location
When the current authorization status is
not, 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
NSLocation key in your app’s
Info 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
location method. If the current authorization status is anything other than
not, this method does nothing and does not call the
You must call this method or the
request method prior to using location services. If the user grants “when-in-use” authorization to your app, your app can start most (but not all) location services while it is in the foreground. (Apps cannot use any services that automatically relaunch the app, such as region monitoring or the significant location change service.) When started in the foreground, services continue to run in the background if your app has enabled background location updates in the Capabilities tab of your Xcode project. Attempts to start location services while your app is running in the background will fail. The system displays a location-services indicator in the status bar when your app moves to the background with active location services.
For more information about the
NSLocation key, see Information Property List Key Reference.