Permissions Handling
Description of required permissions, how to request and manage them.
Required Permissions
On SDK initialization, the host app passes a MoveConfig object to configure which of the SDK services should be activated. Some of those services require system permissions to be granted, or other features to be available.
From a usability perspective, Apple provides some guidelines about Requesting Permissions as part of their Human Interface Guidelines.
The table below shows each of the MoveConfig options and the corresponding required and optional permissions or sensors.
Service | Required permissions | Optional permissions | |
Driving | Driving | Location Permission Precise Location | Motion Permission Background Location Permission |
Distraction-Free-Driving | Gyroscope and Accelerometer availability | ||
Driving Behavior events | Gyroscope and Accelerometer availability | ||
Cycling | Bicycle | Location Permission Motion Permission Precise Location | Background Location Permission |
Walking | Walking | Motion Permission | Background Location Permission |
Location | LocationPermission Precise Location | Background Location Permission | |
Places | Places | LocationPermission Precise Location | |
Points of Interest | Points of Interest | Location Permission Precise Location | Background Location Permission |
Public Transport | Public Transport stops | Location Permission Precise Location | Background Location Permission |
Impact Detection | Impact Detection | Location Permission Precise Location Gyroscope and Accelerometer availability | Motion Permission Background Location Permission |
Assistance Call | Assistance Call | Location Permission Precise Location |
Location Permission
Authorization
This section considers the iOS13 system location permissions changes.
Please check Location Permission Pre iOS13 for more information about handling the permission prior to iOS13
Starting iOS 13, system location is split into 2 layers: CLAuthorizationStatus
and CLAccuracyAuthorization
can be granted with one of the multiple access levels. Focusing only on the MOVE SDK relevant ones:
CLAuthorizationStatus.authorizedAlways
: The user authorized the app to start and access location services at any time. Can be requested by calling requestWhenInUseAuthorization().CLAuthorizationStatus.authorizedWhenInUse
: The user authorized the app to start location services only while the app is in use. Can be requested by calling requestAlwaysAuthorization().
Starting iOS13, when an app requests.authorizedAlways
the system prevents apps from directly receiving the.authorizedAlways
access level, but instead, the system breaks the access into 2 steps. First, it shows the user the permission prompt for.authorizedWhenInUse
and later on, shows the.authorizedAlways
permission prompt when the app (in our case the MOVE SDK embedded in your app) fetches the location in the background for the first time.
Check this WWDC19 session and apple documentation for further information about the iOS13 authorization status changes.
Automatic Detection
The MOVE SDK can automatically wake up the app and activate its services (like trip detection, etc..) fully in the background and without any user interaction, even if the app was killed by the user.
None of the SDK automatic detection services will work except if background location permissionauthorizationAlways
is granted. Otherwise the services will only work when the host app is in the foreground.
Starting iOS13, Apple introduced 2 levels of accuracy access:
.fullAccuracy
: The user authorized the app to access location data with full accuracy..reducedAccuracy
: The user authorized the app to access location data with reduced accuracy.
The MOVE SDK requires full accuracy access to precisely detect trips and deliver high-quality service.
Plist
Apple requires apps requesting any system permission to provide reasoning for granting the permission. This reasoning is known as "purpose string" and is defined in the app's Info.plist
file. Those purpose strings are displayed as an explanation of why the app needs those access types, in the alert shown by the system to ask the user for permission.
In the case of location permission, each access level requires including one or more corresponding keys with purpose strings.
Key | Required if |
Your app requests When In Use authorization or Always authorization. | |
Your app requests Always authorization. | |
Your app supports iOS 10 and earlier and requests Always authorization. |
Background Mode
Moreover, for background location access, Location updates Background Modes must be enabled:
Go to the Capabilities tab of your target settings
Turn on Background Modes and enable Location updates
For more details about how to request location permissions, check out this Apple document.
Sample Code
Requesting.authorizedAlways
location authorization looks something like this:
Motion Permission
plist
Same as with Location permission, Motion permission requires including the NSMotionUsageDescription with its corresponding purpose string in the app's Info.plist
file.
Permission
There is no direct way to request Motion Activities access permission like with Locations. Instead, the permission prompts the first time the Motions API is called.
Requesting the motion permission will look something like this:
Last updated