startLivenessDetectionOnlySDK method

Future<BlusaltLivenessResultResponse?> startLivenessDetectionOnlySDK({
  1. required String apiKey,
  2. required String appName,
  3. required String clientId,
  4. required bool isDev,
  5. LivenessDetectionOnlyType livenessDetectionOnlyType = LivenessDetectionOnlyType.motional,
  6. bool? startProcessOnGettingToFirstScreen,
  7. int? timeoutDurationInSec,
})
override

livenessDetectionOnlyType can be LivenessDetectionOnlyType.motional or LivenessDetectionOnlyType.still or LivenessDetectionOnlyType.flash

timeoutDurationInSec this value can be used top override the timeout duration of networks calls in the SDK. When set to null or no value is passed, it will use the default value from SDK 120s.. @override

Implementation

Future<BlusaltLivenessResultResponse?> startLivenessDetectionOnlySDK(
    {required String apiKey,
    required String appName,
    required String clientId,
    required bool isDev,
    LivenessDetectionOnlyType livenessDetectionOnlyType =
        LivenessDetectionOnlyType.motional,
    bool? startProcessOnGettingToFirstScreen,
    int? timeoutDurationInSec}) async {
  try {
    final result =
        await methodChannel.invokeMethod('startLivenessDetectionOnlySDK', {
      'apiKey': apiKey,
      'appName': appName,
      'clientId': clientId,
      'isDev': isDev,
      'livenessType': livenessDetectionOnlyType.name.toUpperCase(),
      'startProcessOnGettingToFirstScreen':
          startProcessOnGettingToFirstScreen ?? false,
      'timeoutDurationInSec': timeoutDurationInSec,
    });

    if (result != null) {
      var response = json.decode(result);

      var originalByteDataInString =
          (response['faceDetectionData']?['originalLivenessImage'] ??
                  '')
              .toString();
      var byteDataInString =
          (response['faceDetectionData']?['livenessImage'] ?? '').toString();

      return BlusaltLivenessResultResponse(
          livenessResultType: BlusaltLivenessResultType.success,
          isPassProcedureValidation:
              response['isProcedureValidationPassed'] ?? false,
          faceDetectionData: BlusaltFaceDetectionData(
              isPassFaceGenuiness: response['faceDetectionData']
                  ['isPassFaceGenuineness'],
              originalLivenessImageByteWithBg: originalByteDataInString,
              imageByte: byteDataInString));
    } else {
      return BlusaltLivenessResultResponse(
          livenessResultType: BlusaltLivenessResultType.error,
          message: "Something went wrong");
    }
  } on PlatformException catch (exception) {
    return BlusaltLivenessResultResponse(
        livenessResultType: BlusaltLivenessResultType.error,
        exception: exception,
        message: exception.message,
        code: exception.code);
  } catch (e) {
    return BlusaltLivenessResultResponse(
        livenessResultType: BlusaltLivenessResultType.error,
        message: e.toString());
  }
}