Ask the user for permission to access their location.
- Core Location
It’s important to take great care with a user’s location data, and the system requires your app to get the user’s authorization to access this kind of information. To request authorization, call
request, depending on the authorization status your app needs. See Choosing the Location Services Authorization to Request for more information about deciding what type of authorization to request. Your Xcode project must be configured with purpose strings used in the authorization prompts.
Configure Purpose Strings in Xcode
To prepare your app for calling
request, you must add keys with purpose strings to your app's
Info file. The system displays your purpose strings in the authorization request dialogs. Configure the keys in Xcode with the purpose strings that your app requires.
Your app requests When In Use authorization or Always authorization.
Your app requests Always authorization.
Your app runs in macOS and uses location services.
Your app supports iOS 10 and earlier and requests Always authorization.
See the Human Interface Guidelines for more information about purpose strings.
Ask for Authorization During Location-Related Activities
Consider the context of the user's interactions when you request authorization to use their location.
Request authorization only when your user needs location services to perform a task in your app. If it's not clear to the user why your app is using location services, the user may deny your request.
Don't automatically ask for authorization when your app returns to the foreground. If your app has temporary authorization, it loses it when the user stops using your app. Unless the user expects you to continue using their location, wait until the user needs the location to be updated again before requesting authorization.
request to request authorization at the point where you need location services. You may request When In Use authorization as needed; there are no limits on calling
request. The system does limit calls to
request; you may request it only one time.
After making an authorization request, it’s safe to start location services before your request resolves. However, you won't receive location events until your app's authorization status changes to
CLAuthorization. Implement the
location method in your location manager delegate to be notified when your app's authorization status changes.