Dolphin MOVE SDK
SDK
1.x
1.x
  • Introduction
  • MOVE Services
  • MOVE SDK
    • Getting Started
      • MOVE Dashboard
      • Android
        • Installation
        • Quick Start
      • iOS
        • Installation
        • Quick Start
      • React Native
    • API Interface
      • Android
        • Initialization
        • Services
      • iOS
        • Initialization
        • Services
      • React Native
        • Initialization
        • Services
    • Models
      • MoveAuth
      • MoveConfig
      • MoveConfigurationError
      • MoveDeviceStatus
      • MoveSDKState
      • MoveTripState
      • MoveAuthState
      • Listeners/Callbacks
    • Appendix
      • Android
        • Token refresh
        • Permission Handling
        • Battery optimization
        • Notification Management
      • iOS
        • Permissions Handling
        • App Store
  • MOVE Backend
    • MOVE Timeline
    • MOVE State
    • MOVE Last Location
    • MOVE Generic Notifier
    • Open Api Specification
  • Changelog
    • Android
    • iOS
  • Data privacy (GDPR)
Powered by GitBook
On this page
  • Required Permissions
  • Location Permission
  • Authorization
  • Plist
  • Background Mode
  • Sample Code
  • Motion Permission
  • plist
  • Permission
  1. MOVE SDK
  2. Appendix
  3. iOS

Permissions Handling

Description of required permissions, how to request and manage them.

PreviousiOSNextApp Store

Last updated 3 years ago

Required Permissions

On SDK initialization, the host app passes a 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 as part of their Human Interface Guidelines.

The table below shows each of the options and the corresponding required and optional permissions or sensors.

Service

Required permissions

Optional permissions

TimelineDetectionService

Driving

Location Permission

Motion Permission Background Location Permission

Bicycle

Location Permission

Motion Permission

Background Location Permission

Walking

Motion Permission

Background Location Permission

Driving Services

Distraction-Free-Driving (DFD)

Gyroscope and Accelerometer availability

Driving behavior events (DBE)

Gyroscope and Accelerometer availability

Other Services

Points of Interest (POI)

Location Permission

Background Location Permission

If a required permission is missing during or after initialization, the SDK services will stop working and will transit to.permissionMissingerror state.

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

can be granted with one of the multiple access levels. Focusing only on the MOVE SDK relevant ones:

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.

Starting iOS13, Apple introduced 2 levels of accuracy access:

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:

  1. Go to the Capabilities tab of your target settings

  2. Turn on Background Modes and enable Location updates

Sample Code

import CoreLocation
 
class Permission {
    let locationManager = CLLocationManager()
 
    func requestLocationPermission(){
        locationManager.delegate = self
        locationManager.requestAlwaysAuthorization()
    }  
}
 
extension Permission: CLLocationManagerDelegate {
    public func locationManager(_: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
        // status
    }
}

Motion Permission

plist

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:

import CoreMotion
 
func requestCoreMotionPermission(){
    let manager = CMMotionActivityManager()
    let now = NSDate()
 
    manager.queryActivityStartingFromDate(now, toDate: now, toQueue: NSOperationQueue.mainQueue(),
        withHandler: { (activities: [CMMotionActivity]?, error: NSError?) -> Void in
          if let error = error where error.code == Int(CMErrorMotionActivityNotAuthorized.rawValue){
            // "NotAuthorized"
         }else {
            // "Authorized"
         }
    })
}

Starting iOS 13, system location is split into 2 layers: and

:

: The user authorized the app to start and access location services at any time. Can be requested by calling .

: The user authorized the app to start location services only while the app is in use. Can be requested by calling .

Starting iOS13, when an app requeststhe system prevents apps from directly receiving theaccess level, but instead, the system breaks the access into 2 steps. First, it shows the user the permission prompt forand later on, shows thepermission 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 and for further information about the iOS13 authorization status changes.

None of the SDK automatic detection services will work except if background location permissionis granted. Otherwise the services will only work when the host app is in the foreground.

:

: The user authorized the app to access location data with full accuracy.

: The user authorized the app to access location data with reduced accuracy.

For more details about how to request location permissions, check out this Apple .

Requestinglocation authorization looks something like this:

Same as with Location permission, Motion permission requires including the with its corresponding purpose string in the app's Info.plist file.

MoveConfig
Requesting Permissions
MoveConfig
SDKMoveState
CLAuthorizationStatus
CLAccuracyAuthorization
CLAuthorizationStatus
CLAuthorizationStatus.authorizedAlways
requestWhenInUseAuthorization()
CLAuthorizationStatus.authorizedWhenInUse
requestAlwaysAuthorization()
.authorizedAlways
.authorizedAlways
.authorizedWhenInUse
.authorizedAlways
session
apple documentation
authorizationAlways
CLAccuracyAuthorization
.fullAccuracy
.reducedAccuracy
document
.authorizedAlways
NSMotionUsageDescription
NSLocationWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
Location updates background mode capability