To get current location permission status, use the sdkStatus property.
let sdkStatus = Sentiance.shared.sdkStatus
if (sdkStatus.locationPermission == .always) {
// We are good!
} else {
// Background location permission not granted.
}
if (sdkStatus.isPreciseLocationAuthorizationGranted) {
// We are good!
} else {
// Precise location permission not granted.
}
val sdkStatus = Sentiance.getInstance(context).sdkStatus
if (sdkStatus.locationPermission == SdkStatus.LocationPermission.ALWAYS) {
// We are good!
} else {
// Background location permission not granted.
}
if (sdkStatus.isPreciseLocationPermGranted) {
// We are good!
} else {
// Precise location permission not granted.
}
import SentianceCore from "@sentiance-react-native/core";
const sdkStatus = await SentianceCore.getSdkStatus();
if (sdkStatus.locationPermission === "ALWAYS") {
// We are good!
} else {
// Background location permission not granted.
}
if (sdkStatus.isPreciseLocationAuthorizationGranted) {
// We are good!
} else {
// Precise location permission not granted.
}
import 'package:sentiance_core/sentiance_core.dart';
final sentiance = SentianceCore();
final sdkStatus = await sentiance.getSdkStatus();
if (sdkStatus.locationPermission == LocationPermission.always) {
// We are good!
} else {
// Background location permission not granted.
}
In the above example, sdkStatus returns an SDK status object (iOS / Android) which has properties for the location permission and precision.
The user must grant the background location access permission in order for SDK detections to work. This is presented as the "always" option on iOS, and the "allow all the time" option on Android 10+ devices.
The user must also enable precise location accuracy.
To be notified of location permission changes, you can set up an SDK status listener on the SDK's config object as follows:
Sentiance.shared.setDidReceiveSdkStatusUpdateHandler { status in
// Check the location permission and precision here.
}
Sentiance.getInstance(this).setSdkStatusUpdateListener { status ->
// Check the location permission and precision here.
}
import SentianceCore from "@sentiance-react-native/core";
const subscription = await SentianceCore.addSdkStatusUpdateListener(
sdkStatus => {
// Check the location permission and precision here.
}
);