SDK Lifecycle

CafLivenessListener (Flutter)

The CafLivenessListener in Flutter handles key events during the SDK's liveness detection process. Below are the events you can listen to for FaceLiveness:

Event

Description

FaceLivenessEventConnecting

Indicates the SDK is initializing or connecting to the server.

FaceLivenessEventConnected

Triggered when the SDK is fully connected, and the user interface will be displayed.

FaceLivenessEventClosed

Triggered when the user cancels the liveness detection process.

FaceLivenessEventSuccess

Triggered upon successful liveness detection, providing the result in signedResponse.

FaceLivenessEventFailure

Called when an SDK failure occurs, providing error details like errorType and errorDescription.

Example Implementation

Below is an example of how to handle CafLivenessListener events in Flutter:

void _setupFaceLivenessListener(Stream<FaceLivenessEvent> stream) {
  stream.listen((event) {
    if (event is FaceLivenessEventConnecting) {
      print('Connecting to FaceLiveness...');
    } else if (event is FaceLivenessEventConnected) {
      print('Connected to FaceLiveness.');
    } else if (event is FaceLivenessEventClosed) {
      print('SDK closed by the user.');
    } else if (event is FaceLivenessEventSuccess) {
      print('Success! SignedResponse: ${event.signedResponse}');
    } else if (event is FaceLivenessEventFailure) {
      print(
        'Failure! Error type: ${event.errorType}, '
        'Error description: ${event.errorDescription}',
      );
    }
  });
}

Last updated

Logo

2023 © Caf. - All rights reserved