Passive Liveness Detection

Declaration

func openPassiveLivenessDetection(
    on viewController: UIViewController, 
    doneLaunching: SybrinBiometrics.doneLaunchingType? = nil, 
    success: SybrinBiometrics.passiveLivenessDetectionSuccessCallbackType? = nil, 
    failure: SybrinBiometrics.failureCallbackType? = nil, 
    cancel: SybrinBiometrics.cancelCallbackType? = nil
)

To view all the type aliases, go to the SybrinBiometrics class

Handling the doneLaunching , success , failureor cancel callbacks are optional but recommended.

Calling the function

Parameters

Handling callback responses

doneLaunching

The doneLaunching callback will be executed after the view controller has successfully launched, or if the view controller failed to launch.

Parameters:

Example:

doneLaunching: { (didLaunch, message) in
    if didLaunch {
        print("Launched successfully!")
    } else if let message = message {
        print("Failed to launch because \(message)")
    }
}

success

The success callback will be executed after the session has finished and the view controller has been dismissed.

Parameters:

Example:

success: { (model) in
    print("Passive liveness detection finished. You are \(model.isAlive ? "\(model.livenessConfidence * 100)% alive" : "\((1 - model.livenessConfidence) * 100)% not alive")
}

failure

The failure callback will be executed after the session has failed and the view controller has been dismissed.

Parameters:

If you would like to report a bug, contact us!

Example:

failure: { (message) in
    print("Passive liveness detection failed because \(message)")
}

cancel

The cancel callback will be executed after the user has dismissed the view controller and before the session could finish.

Parameters:

None

Example:

cancel: {
    print("Passive liveness detection canceled")
}

Full Example

SybrinBiometrics.shared.openPassiveLivenessDetection(on: self) 
{ (didLaunch, message) in
    if didLaunch {
        print("Launched successfully!")
    } else if let message = message {
        print("Failed to launch because \(message)")
    }
} success: { (model) in
    print("Passive liveness detection finished. You are \(model.isAlive ? "\(model.livenessConfidence * 100)% alive" : "\((1 - model.livenessConfidence) * 100)% not alive")")
} failure: { (message) in
    print("Passive liveness detection failed because \(message)")
} cancel: {
    print("Passive liveness detection canceled")
}

Last updated