For the complete documentation index, see llms.txt. This page is also available as Markdown.

App Permissions

Learn how to request the permissions the Sentiance SDK needs at runtime, and what happens to detections when one is missing.

The Sentiance SDK requires a set of permissions to function and perform detections correctly. Some permissions are mandatory, while others are optional or automatically granted by the system.

Declaring a permission is not the same as holding it. The SDK does not request permissions on your behalf, so your app must ask the user for them at runtime. For the manifest and Info.plist declarations, and for the full list of permissions, check out the requirements page for Android and iOS.


Overview

Permission
Platform
Required
Without it

Background location "Always" on iOS, "Allow all the time" on Android

iOS, Android

Mandatory

Detections will not run. The detection status stays "enabled but blocked".

Precise location

iOS, Android

Mandatory

Detections will not run. Approximate location is not sufficient.

Motion & Fitness / Activity Recognition

iOS, Android

Optional

Detections run, with reduced quality.

Notifications

Android 13+

Optional

Detections run, but the foreground service notification is not shown.


Requesting Location Access

Both platforms grant background location in two stages. Your app must request foreground access first, and only then request background access.

Call requestWhenInUseAuthorization() first, and call requestAlwaysAuthorization() only once the "When In Use" authorization has been granted. iOS then asks the user whether to allow location access always.

import CoreLocation

class PermissionHandler: NSObject, CLLocationManagerDelegate {
    private let locationManager = CLLocationManager()

    func requestLocationPermission() {
        locationManager.delegate = self
        locationManager.requestWhenInUseAuthorization()
    }

    func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
        switch manager.authorizationStatus {
        case .authorizedWhenInUse:
            // Ask to extend the authorization to the background
            manager.requestAlwaysAuthorization()
        case .authorizedAlways:
            // Precise Location must also be enabled
            if manager.accuracyAuthorization == .fullAccuracy {
                NSLog("Location permission granted")
            } else {
                NSLog("Precise Location is off, detections will not run")
            }
        default:
            NSLog("Location permission not granted")
        }
    }
}

Handle the outcome in locationManagerDidChangeAuthorization(_:) rather than at the call site, since the user can change the authorization at any time from the Settings app.

From Android 11 (API level 30), ACCESS_BACKGROUND_LOCATION cannot be requested in the same call as foreground location. Request ACCESS_FINE_LOCATION first, and request background access in a separate call once it has been granted.

On Android 11 and above, the system does not show a dialog for the second request. It opens your app's location settings screen instead, where the user selects Allow all the time. This is enforced by Android.

Request the two Android permissions in sequence. On iOS, location permissions are requested through the native layer, so follow the iOS instructions above.

Use a permission plugin such as permission_handler, and request the two permissions in sequence.

Precise Location

A user can grant background access while leaving precise location off, in which case detections will not run.

On iOS, check that accuracyAuthorization is .fullAccuracy. A temporary grant through requestTemporaryFullAccuracyAuthorization(withPurposeKey:) is not sufficient for the SDK, since the SDK requires precise location in the background. The user must enable Precise Location for your app in the Settings app.

On Android, requesting ACCESS_FINE_LOCATION gives the user the choice between Precise and Approximate in the same dialog. If they choose approximate, request the permission again to prompt for an upgrade.


Requesting Motion Access

This permission is optional. When granted, it helps improve the quality of the detections. Therefore, it is highly recommended to ask the user to grant this permission.

The Motion & Fitness permission is requested by iOS the first time your app queries CMMotionActivityManager. There is no separate request method.

Make sure NSMotionUsageDescription is set in your Info.plist, otherwise your app will be terminated when the permission is requested. This is enforced by iOS.

On Android 10 (API level 29) and above, request the ACTIVITY_RECOGNITION permission. This is a standard runtime request with a dialog.


Requesting Notification Access

On Android 13 (API level 33) and above, the POST_NOTIFICATIONS permission decides whether the SDK's foreground service notification is visible to the user.

Detections are not affected by this permission. The foreground service still runs, but its notification is suppressed until the permission is granted. If you have customized this notification, this is the permission that determines whether anyone sees it.

For more about the foreground service and its notification, check out this page.


Verifying the Result

Do not rely on the result of your permission requests alone. The user can revoke a permission at any time from the system settings, and a granted permission does not always mean the SDK can detect. Read the effective state back from the SDK instead.

SDK Status field
What to check

locationPermission

Must be ALWAYS. ONLY_WHILE_IN_USE means the second request did not complete.

isPreciseLocationAuthorizationGranted

False when the user granted approximate location only.

isActivityRecognitionPermGranted

Motion & Fitness on iOS, Activity Recognition on Android.

detectionStatus

ENABLED_BUT_BLOCKED while any mandatory permission is missing.

For the full list of SDK status fields and what each one means, check out this page. To be notified when a permission changes while your app is running, subscribe for SDK status updates.


For the complete overview of platform-specific requirements, check out the following pages:

iOSAndroid

Last updated