Start Liveness Verification

Calling start

To start document detection, initialize DocumentDetector with the necessary configurations, then call start() and handle events using a listener:

void startDocumentDetector(List<DocumentCaptureFlow> captureFlow) async {
  String personId = personIdController.text;
  String mobileToken = mobileTokenController.text;

  DocumentDetector documentDetector =
  DocumentDetector(mobileToken: mobileToken, captureFlow: captureFlow);

  // Configure Android-specific settings
  AndroidSettings androidSettings = AndroidSettings(
      securitySettings: SecuritySettings(
          useAdb: true,
          useDebug: true,
          useDeveloperMode: true,
          useEmulator: true,
          useRoot: true));

  documentDetector.setAndroidSettings(androidSettings);
  documentDetector.setNetworkSettings(20);
  documentDetector.setStage(isBeta ? CafStage.beta : CafStage.prod);
  documentDetector.setPersonId(personId);
  documentDetector.setPreviewSettings(PreviewSettings(show: true));

  try {
    DocumentDetectorEvent event = await documentDetector.start();
    // Handle the result
    if (event is DocumentDetectorEventSuccess) {
      print("SUCCESS: ${event.documentType}");
    } else if (event is DocumentDetectorEventFailure) {
      print("FAILURE: ${event.errorMessage}");
    } else if (event is DocumentDetectorEventClosed) {
      print("User closed document capture flow");
    }
  } catch (e) {
    print("Error starting DocumentDetector: ${e}");
  }
}

Last updated

Logo

2023 © Caf. - All rights reserved