With the introduction of iOS 14 there is a new set of terms that developers should learn. Things like Approximate vs. Precise Location will be important for developers to understand, that way key stakeholders can make informed decisions about how to shape the Product & User Experience. For more information about these changes, please visit our iOS 14 Guide.
Along with understanding what changes have been made, it's important to understand how to make those changes as well. In order to help, Gimbal is providing the key code snippets that will be important for iOS 14+ developers to implement.
When In Use vs. Always Location
With the introduction of iOS 13, Apple created a flow that requires developers to ask for location permissions twice in order to receive Always Allow location data. After studying the impact of this over the past year, Gimbal has decided to recommend only requesting Always Allow if your app provides value to the end-user. Examples of this include a robust in-store mode, offering a unique BOPIS or Curbside experience, or any feature that requires tracking of that user's location for unique deals & offers. Even for apps that do request Always Allow location data, we still recommend only requesting this data when absolutely necessary. This means you should prompt your users for When In Use using the following code as part of CLLocationManager:
func requestWhenInUseAuthorization()
Then, only once you've provided value to the end user and have a valid reason to request Always Allow, should you request Always Allow location data from the user. This is accomplished using the following code as part of CLLocationManager:
func requestAlwaysAuthorization()
Precise vs. Approximate Location
Apple is increasing app users' abilities to obfuscate their location data with a new feature called Precise Location. This is a toggle that allows users to turn their Precise Location to Off, which at a developer level returns a value of 1,000 - 10,000 meters of potential location data for that user. This data has no specific identifiers that would allow anyone to understand where exactly that user is at in relation to the region returned, and instead the developer receives just an Approximate value for that user's location. Understanding if a user has changed this location data is key to handling the user experience correctly. In order to listen for changes by the user, developers should implement the below code:
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
let precise = manager.accuracyAuthorization
switch precise {
// Default Precision Level
case .fullAccuracy:
break
// User Reduced Manually
case .reducedAccuracy:
// Create Temporary Request for Precise Location
manager.requestTemporaryFullAccuracyAuthorization(withPurposeKey: "Curbside")
break
default:
break
}
}
As part of that code, you'll notice there is a request for temporary access to a user's precise location data. This function is extremely valuable for instances when the user has turned the Precise: Off, however your app still needs accurate location information in order to facilitate a better user experience. This request, when granted, will provide Precise location data for that user for the rest of the app's session; once the app is terminated, either by the user or OS, this Precise location data will no longer be available. This request can be made more than once.
Lastly, if your app does include the request for temporary access to a user's location data, you will need to include a specific usage string in your app's info.plist. This will explain to the user why your app is requesting temporary access to the Precise location data, and helps provide a better user experience. The following is an example of a few reasons that might be included as part of a temporary request to the user's Precise location data:
<dict>
<key>Curbside</key>
<string>Deliver Curbside Orders When You Arrive</string>
<key>InStoreMode</key>
<string>Create A Unique In-Store Experience</string>
<key>AutoCheckIn</key>
<string>No Touch Check-In Upon Your Arrival</string>
</dict>
Comments
0 comments
Please sign in to leave a comment.