enableDetections method

Future<void> enableDetections()

Enables SDK detections. Requires a Sentiance user to be present on the device. Enabling detections is persistent across app restarts. Therefore, you do not need to call this method on every app startup. Once detections are enabled, as long as the SDK is properly initialized during startup, detections will be resumed, until you disable them by calling [disableDetections].


Enabling detections does not mean that the SDK is successfully able to start all detections. There may be unsatisfactory conditions that are blocking some detections. Check the [DetectionStatus] returned in the result to see if detections are running, and the [SdkStatus] to identify possible causes if not.


To automatically disable detections after some time, use the [enableDetectionsWithExpiryDate] variant of this method.

You must have initialized the SDK before invoking this function.

Throws a PlatformException if an error occurs when communicating with the host platform.
Throws a EnableDetectionsError if the SDK fails to enable detections.

Example:

try {
  await enableDetections();
} on PlatformException catch(e) {
  // An error occurs when communicating with the host platform.
} on EnableDetectionsError catch(e) {
  // Failed to enable detections, find out more about the reason why
  final reason = e.reason;
}

Implementation

Future<void> enableDetections() async {
  return _api.enableDetections().catchSentianceErrorAndRethrow(
      EnableDetectionsError.fromNativeErrorMap);
}