iOS 14+ Privacy through location permissions

This post has been republished via RSS; it originally appeared at: Microsoft Mobile Engineering - Medium.

With every new release iOS, Apple is changing its privacy options by inclining them more towards the mobile device user. This empowers the mobile device users to gain the insights on the information which the mobile apps are using, including microphone, camera, notifications, locations, etc. Mobile device users can now choose to grant or restrict mobile apps to use this aforementioned information.

On the other hand, with every release of iOS, it’s becoming difficult for the app owners to fetch the user related information from their mobile devices. One such example is New Location permissions settings which have been introduced as a part of iOS-14+.

Location permissions in iOS-13

iOS-13 had four different options for accessing the location, and user was prompted to choose from these available options. These options are mentioned below

  1. Don’t allow
  2. Ask next time
  3. While in use
  4. Always allow

When a user will first install the app and open it, they need to pick up their choice, of WHEN to access the location, from the above options based upon their requirement.

Location permissions in iOS-14+

iOS-14 introduced more advanced features when it comes to user location permissions. Mobile device users now can choose to share their approximate location rather than the accurate location. This is controlled by switching ON/OFF the option of precise location. Let’s understand it in deep with example.

An app which requires user’s location to deliver services will ask the user for location authorization. This is done by first seeking the permission through the api — locationManager.requestAlwaysAuthorization(). User is given a prompt as shown below.

iOS 14+ Location permission prompt

If we observe here, Apple has removed the option of “Always allow” from the first prompt that appears to the mobile device user. Additionally, you will notice an option of Precise Location which user may choose to turn ON/OFF as per their requirement.

Precise Location

If existing location permission settings are WHEN for accessing the location of the user, then precise location is the HOW for accessing the same location. The possible values of precise location are ON or OFF.

When precise location is ON, the app can access the exact location of the user including its street and the block from where the user is accessing the app. Further, if user is on the move, this location will be updated accurately as per user’s movement. For reference, check the image below.

Precise Location ON accuracy

On the other hand, when a user turns OFF the precise location, iOS creates a perimeter of radius 1km to 10km (depending upon the population density at which user is there) and user can be anywhere inside of that radius. Further, the background location update, in this case, happens only after every 15 mins. When a user is on the move, the location update will happen as mentioned below

  1. If the original perimeter is not breached, i.e. user is moving but its still under that same perimeter area, the location will not get updated even in the next location check after 15 mins.
  2. If the user moved outside of perimeter fence, another geo-fence will be created at the time of next access to user’s location which will happen after 15 mins from its previous time.

Below diagram explains about how geo-fences and perimeters are created by Apple.

Precise Location OFF accuracy

iOS-14+ Core Location APIs

Requesting location permissions

To request location permissions when the app runs, use the below code to show the prompt to the user.

locationManager.requestAlwaysAuthorization()

Delegate methods to receive change in Location permissions.

When a user selects an option from the prompt shown as the part of above step, or if the user goes into Settings, and changes the location permissions — below mentioned delegate APIs are invoked (please note the difference in iOS 13/14 version in both delegate methods)

Delegate method to receive Location Permissions in iOS-13
Delegate method to receive Location Permissions in iOS-14+

Delegate method to receive change in precise location permissions.

When user changes the option for Precise Location permission settings (to ON or OFF), the below delegate method is invoked. Please note here that it’s the same delegate method which gets invoked when location permissions too are changed in case of iOS-14+.

Delegate method to receive Precise Location permission updates

Delegate method to receive change in precise location permissions.

Requesting location permissions from the user requires adding keys with purpose strings into the app’s Info.plist file. The string value specified for this key will appear in the “location access requesting dialog” and is a way to inform users why the app needs location permissions.

Here are the keys (from Apple’s documentation) that can be included as per app’s use-case.

Keys

  1. NSLocationWhenInUseUsageDescription — Your app requests’When In Use’ authorization or ‘Always’ authorization.

2. NSLocationAlwaysAndWhenInUseUsageDescription — Your app requests Always authorization.

3. NSLocationUsageDescription — Your app runs in macOS and uses location services.

4. NSLocationAlwaysUsageDescription — Your app supports iOS 10 and earlier and requests Always authorization.

Conclusion

I hope this article gave a high level idea on how location permissions are configured in iOS 14+. The technical terms used for locations permissions include ‘Authorization Status’ for general permissions like ‘Always’, ‘While in Use’ and ‘Accuracy Authorization’ for precise location option like ‘Reduced’ (OFF) or ‘Full’ (ON).

Thanks to Sarang Deshpande and ravi krishnan for motivating me to write this article and Cesar Valiente for his guidance in shaping the article.


iOS 14+ Privacy through location permissions was originally published in Microsoft Mobile Engineering on Medium, where people are continuing the conversation by highlighting and responding to this story.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.