Ask or search…
K
Links
Comment on page

FaceAuthenticator

Facematch with proof of life from your app's user, ideal for login flows or valuable financial transactions.

Required permissions

In the info.plist file, add the permissions below:
Permission
Reason
Required?
Privacy - Camera Usage Description
To capture the user selfie
Yes

Utilization

First, instantiate an object of type FaceAuthSDK:
let faceAuthenticator = FaceAuthSDK.Builder()
// see the table below
.build()

FaceAuthSDK.Builder

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:
  • `Time.THREE_HOURS`
  • `Time.THIRTY_DAYS`
No

Getting the result

To get the result, you must implement the FaceAuthSDKDelegate delegate in your class:
faceAuthenticator?.delegate = self

Delegate Implementation

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 ViewController: FaceAuthSDKDelegate {
func didFinishSuccess(with faceAuthenticatorResult: FaceAuthenticatorResult){
}
func didFinishWithError(with faceAuthenticatorErrorResult: FaceAuthenticatorErrorResult){
}
func didFinishWithCancell(with faceAuthenticatorResult: FaceAuthenticatorResult){
}
func didFinishWithFail(with faceAuthenticatorFailResult: FaceAuthenticatorFailResult){
}
func openLoadingScreenStartSDK(){
}
func closeLoadingScreenStartSDK(){
}
func openLoadingScreenValidation(){
}
func closeLoadingScreenValidation(){
}
}

Result Objects

At the end of a successful execution case, you will receive an object of type 'faceAuthenticatorResult.' This object carries a 'signedResponse' property containing a JWT token with the execution result. This token should be decrypted to obtain the execution results.
faceAuthenticatorResult.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 FaceAuthFailResult)

Signed response params

Event
Description
requestId
Request identifier.
isAlive
Validation of a living person, identifies whether the user passed successfully or not.
isMatch
Face match validation result.
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.
message
Return message.
The isAlive parameter is VERY IMPORTANT, based on it validation must be carried out to continue with the flow or not, in the case of isAlive: true your user can continue with the journey, in the case of isAlive: false, this user is not valid and should be barred from the rest of the journey. Furthermore, the isMatch parameter indicates whether the Face Match passed successfully or not, returning isMatch: true in case of success and false in case of failure.

Handling Errors and Failures

In the case of errors and failures, the objects will be faceAuthenticatorErrorResult and faceAuthenticatorFailResult, respectively. These objects return an enum with the error or failure, an error code, and a brief description.
In case of failure, the faceAuthenticatorFailResult 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

LoadScreen

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