Asking for permission to access location data

When you do need access to a user's location, you have to ask permission first. Similar to how you have to add a reason for needing the camera or a user's contacts to the Info.plist file, you must also provide a reason for requesting location data. In the case of location data, there are two keys you can add to the Info.plist:

  • Privacy-Location When In Use Usage Description (NSLocationWhenInUseUsageDescription)
  • Privacy-Location Always And When In Use Usage Description (NSLocationAlwaysAndWhenInUseUsageDescription)

When your app asks for permission to use a user's location data, they have the option to only allow your app access to their location when the app is in use, or they can choose to allow ...

Get Mastering iOS 12 Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.