Comment on page
FaceLiveness
Smart camera that captures a reliable selfie of your user using artificial intelligence, capable of detecting and disapproving snapshots and recordings. Ideal for your onboarding.
In the
info.plist
file, add the permissions below:Permission | Reason | Required? |
Privacy - Camera Usage Description | To capture the user selfie | Yes |
First, instantiate an object of type
FaceLivenessSDK
:let faceLiveness = FaceLivenessSDK.Build()
// see the table below
.build()
Parameter | Required? |
.setCredentials(token: String, personId: String) token: Usage token associated with your CAF account personId: identifier of the user in which is registered the face of the user who will perform the facematch. Currently, this value only accepts the user's CPF. | Yes |
.setFilter(filter: Filter) filter: Camera filter type, if not placed return lineDrawing as a default filter | No |
.setLoadingScreen(withLoading: Bool) withLoading: This boolean parameter determines whether the loading screen will be implemented via a delegate or if you will use the default screen. If set to 'true,' the loading screen will be a standard SDK screen. In the case of 'false,' you should use the 'LoadingScreen' session and implement the delegates. | No |
.setImageUrlExpirationTime(Time time) Used to customize the image URL expiration time, that has the following options:
| No |
| | | - |
To get the result, you must implement the
FaceLivenessDelegate
delegate in your class:faceLiveness?.delegate = self
The delegate below must be implemented to handle the SDK results. When implementing the delegate extension, you will have access to an object depending on the return type. In each case, the object carries different information.
extension FaceAuthenticatorViewModel: FaceLivenessDelegate {
func didFinishWithFail(with faceLivenessFailResult: FaceLivenessFailResult) {
//handle result
}
func didFinishWithError(with faceLivenessErrorResult: FaceLivenessErrorResult) {
//handle result
}
func didFinishLiveness(with faceLivenessResult: FaceLivenessResult) {
//handle result
}
func didFinishWithCancelled(with faceLivenessResult: FaceLivenessResult) {
//handle result
}
func openLoadingScreenStartSDK() {
}
func closeLoadingScreenStartSDK() {
}
func openLoadingScreenValidation() {
}
func closeLoadingScreenValidation() {
}
}
At the end of a successful execution case, you will receive an object of type 'FaceLivenessResult.' This object carries a 'signedResponse' property containing a JWT token with the execution result. This token should be decrypted to obtain the execution results.
faceLivenessResult.signedResponse
The delegate also includes returns for execution cancellations, failures, and errors. You can implement these functions as necessary for these flows.
Within the signedResponse, the parameter isAlive defines the execution of liveness, where true is approved and false is rejected(in case of isAlive false see the object
FaceLivenessFailResult
)Event | Description |
requestId | Request identifier. |
isAlive | Validation of a living person, identifies whether the user passed successfully or not. |
token | Request token. |
userId | User identifier provided for the request. |
imageUrl | Temporary link to the image, generated by our API. |
personId | User identifier provided for the SDK. |
sdkVersion | Sdk version in use. |
iat | Token expiration. |
The isAlive parameter is VERY IMPORTANT, based on it validation must be carried out to continue with the flow or not, in case of
isAlive: true
, your user is able to continue with the journey, in case of isAlive: false
, this user is not is valid and should be barred from the remainder of the journey.In the case of errors and failures, the objects will be
FaceLivenessErrorResult
and FaceLivenessFailResult
, respectively. These objects return an enum with the error or failure, an error code, and a brief description.In case of failure, the
FaceLivenessFailResult
object will also return a signedResponse containing information. Within the signedResponse, the parameter isAlive defines the execution of liveness, where true is approved and false is rejected.Code | Enum Error value | Description |
---|---|---|
0 | unknown | Try aganin |
1 | getToken | Error while trying to capture the execution token. |
2 | livenessError | Error while attempting to execute liveness due to communication issues. |
3 | registerError | Error while performing the registration of the liveness execution. |
4 | captureAlreadyActive | An existing capture is already in progress. Wait until the current capture completes before starting a new one. |
5 | cameraPermissionDenied | The user disallowed access to the camera when prompted. You should direct the user to re-try. |
6 | networkError | An error occurred with the video streaming process. The associated string (if available) will contain further information about the error. |
7 | serverError | A server-side error/token invalidation occurred. The associated string (if available) will contain further information about the error. |
8 | unexpectedError | An unexpected and unrecoverable error has occurred. The associated string will contain further information about the error. These errors should be reported to iProov for further investigation. |
9 | userTimeout | The user has taken too long to complete the claim. |
10 | notSupported | The device is not supported |
To create a loading screen during the SDK validation processes, you need to implement a view with the loading screen and display this screen in the open and close delegate function.
The second step is, when initializing the SDKs, it is necessary to add the view to the view stack using the following code. This makes the view visible.
view.addSubview(loadingHUD)
This view should be added before the Builder of each SDK.
Last modified 3d ago