Check for Settings Errors
Getting Fairmatic SDK settings on demand
If you want to check for the current errors in the SDK, you can do it using Fairmatic.getSettings(completionHandler)
method. This method returns an object of the Settings
class, and you can use the retrieved settings errors to determine whether any action is needed to rectify settings that affect SDK functionality.
- Swift
- Objective-C
func checkForFairmaticErrors() {
Fairmatic.getSettings { settings in
guard settings.errors.isEmpty else {
NSLog("No settings errors found.")
return
}
for settingsError in settings.errors {
switch settingsError.errorType {
case .locationServiceOff:
print("Location services off")
case .locationPermissionNotAuthorized:
print("Location permission not authorized. Make sure you allow always access to location")
case .locationAccuracyAuthorizationReduced:
print("Location accuracy reduced")
case .activityPermissionNotAuthorized:
print("Motion and fitness permission not authorized")
@unknown default:
print("-")
}
}
}
}
- (void) checkFairmaticSettings {
[Fairmatic getSettingsWithCompletionHandler:^(FairmaticSettings *settings) {
NSArray *settingsErrors = settings.errors;
if (settingsErrors.count > 0) {
for (FairmaticSettingsError *error in settingsErrors) {
switch (error.errorType) {
case FairmaticSettingsErrorTypeLocationServiceOff:
NSLog(@"Location services off");
break;
case FairmaticSettingsErrorTypeLocationPermissionNotAuthorized:
NSLog(@"Location permission not authorized. Make sure you allow always access to location");
case FairmaticSettingsErrorTypeLocationAccuracyAuthorizationReduced:
NSLog(@"Location accuracy reduced");
case FairmaticSettingsErrorTypeActivityPermissionNotAuthorized:
NSLog(@"Motion and fitness permission not authorized");
default:
break;
}
}
} else {
NSLog(@"No errors to resolve from Fairmatic!");
}
}];
}