Search…
Check the Location Permissions
To get current location permission status, use the getSdkStatus method (iOS / Android).
iOS
Android
1
SENTSDKStatus *currentStatus = [[SENTSDK sharedInstance] getSdkStatus];
2
if(currentStatus.isLocationPermGranted) {
3
// We are good!
4
} else {
5
// Permission denied
6
}
Copied!
1
SdkStatus currentStatus = Sentiance.getInstance(context).getSdkStatus();
2
if(currentStatus.isLocationPermGranted) {
3
// We are good!
4
} else {
5
// Permission denied
6
}
Copied!
In the above example, getSdkStatus returns an SDK status object (iOS / Android) which has an isLocationPermGranted field, indicating if the correct permission has been granted by the user to allow SDK detections.
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+.
To be notified of SDK status changes such as permission changes, quota updates, and the detection or SDK start status, you can set up an SDK status listener on the SDK's config object as follows:
iOS
Android
1
SENTConfig *conf = [[SENTConfig alloc] initWithAppId:APPID
2
secret:SECRET launchOptions:launchOptions];
3
4
conf.didReceiveSdkStatusUpdate = ^(SENTSDKStatus *status) {
5
if(status.isLocationPermGranted) {
6
//We are good!
7
} else {
8
//Permission denied
9
}
10
};
11
12
[[SENTSDK sharedInstance] initWithConfig:conf
13
success:^{
14
// SDK init success.
15
// Start SDK here
16
} failure:^(SENTInitIssue issue) {
17
//SDK Failed to init
18
}];
Copied!
1
SdkConfig config = new SdkConfig.Builder(appId, secret, notification)
2
.setOnSdkStatusUpdateHandler(new OnSdkStatusUpdateHandler() {
3
@Override
4
public void onSdkStatusUpdate (SdkStatus status) {
5
if (status.isLocationPermGranted) {
6
//We are good!
7
} else {
8
//Permission denied
9
}
10
}
11
})
12
.build();
13
14
// Initialize the Sentiance SDK.
15
Sentiance.getInstance(this).init(config, this);
Copied!
Copy link