Comment on page
FaceAuthenticator (Deprecated)
Facematch with proof of life from your app's user, ideal for login flows or valuable financial transactions.
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
FaceAuthenticator
:let faceAuthenticator = FaceAuthenticator.Builder(mobileToken: "mobileToken")
// see the table below
.build()
Parameter | Required? |
String mobileToken Usage token associated with your CAF account | Yes |
.setPeopleId(_ peopleId: String) 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 |
.setAnalyticsSettings(useAnalytics: Bool) | No. The default is true |
.setStabilitySensorSettings(message: String?, stabilityThreshold: Double?) Changes the default settings of the stability sensor. The threshold of this sensor is in the range of the last two accelerations collected from the device. | No. The default is "Keep the phone still" and 0.3, respectively |
.setLayout(layout: PassiveFaceLivenessLayout) Changes the document masks for success, failure and normal. Also allows you to change the sound and cancel buttons, which are at the top of the screen | No |
.setColorTheme(color: UIColor) Change the color of the sound and cancel buttons that are at the top of the screen. Also change the color of the popup buttons, inflated before each document. | No |
.enableSound(enableSound: Bool) Enables/disables sounds and the sound icon in the SDK | No. The default is true |
.setNetworkSettings(requestTimeout:TimeInterval) Change the default network settings | No. The default is 60 (seconds) |
.setImageCaptureSettings(beforePictureInterval: TimeInterval!, enableManualCapture: Bool, timeManualCapture: TimeInterval) Allows you to set the capture per image. The beforePictureInterval attribute sets the time the user should stay with the face docked in the mask. The enableManualCapture attribute enables or disables manual capture. And timeManualCapture defines the time at which manual capture will be enabled. | No. The default is enabled. For beforePictureInterval the default is 2 (seconds). For enableManualCapture the default is true and for timeManualCapture the default is 10 (seconds). |
.setVideoCaptureSettings(time: TimeInterval) Video capture setting method | No |
.setEyesClosedSettings(threshold: Double, isEnable: Bool, errorMessage: String) Allows to customize the SDK's eyes closed validation settings. The method takes as parameter isEnable to enable or disable the validation, threshold , value between 0.0 and 1.0, and errorMessage, to set the message in case closed eyes are detected. | No. The default is true , 0.5 is "Don't wear sunglasses and keep your eyes open". |
.setStage(stage: CAFStage) Allows you to choose the environment in wich the SDK will run (production, beta). The method takes as parameter an enum CAFStage to select the environment: | No. The default is .PROD |
Enum | Description |
.PROD | Will use the Trust Platform production environment to register the SDK executions. |
.BETA | Will use the Trust Platform beta environment to register the SDK executions. |
Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.
After creating the
FaceAuthenticator
type object, you can start the FaceAuthenticatorController
by passing it as a parameter in the constructor:let faceAuthController = FaceAuthenticatorController(faceAuthenticator: faceAuthenticator)
faceAuthController.faceAuthenticatorDelegate = self
present(faceAuthController, animated: true, completion: nil)
To get the result, you must implement the
FaceAuthenticatorControllerDelegate
delegate in your controller:class YouController: UIViewController, FaceAuthenticatorControllerDelegate{
// MARK: Delegates Face Auht
func faceAuthenticatorController(_ faceAuthenticatorController: FaceAuthenticatorController, didFinishWithResults results: FaceAuthenticatorResult) {
//Called when the process was successfully executed
//The result variable contains the data obtained
}
func faceAuthenticatorControllerDidCancel(_ faceAuthenticatorController: FaceAuthenticatorController) {
//Called when the process was canceled by the user
}
func faceAuthenticatorController(_ faceAuthenticatorController: FaceAuthenticatorController, didFailWithError error: FaceAuthenticatorFailure) {
//Called when the process terminate with an error
//The error variable contains info about error
}
}
Parameter | Can it be null? |
authenticated: Bool Flag indicating whether the user's selfie passed the facematch with the photo stored on the CAF server with the respective CPF | No |
signedResponse: String Signed response from the CAF server that performed the facematch. Use this parameter if you want an extra layer of security by checking that the signature of the response is not broken, caused by an intercepted request. If it is broken, there is a strong indication of request interception | Yes, in case of error |
trackingId: String? Identifier of this run on our servers. If possible, save this field and send it along to our API. This way we will have more data about how the user behaved during the execution | Yes, if the user sets useAnalytics = false or the analytics calls do not work |
lensFacing: Int Defines the face of the camera that was used. Use FaceAuthenticatorResult.LENS_FACING_FRONT or FaceAuthenticatorResult.LENS_FACING_FRONT to validate. | No |
Superclass that leads to the SDK shutdown. To find out what the reason was, find out which object class has the
isKindOfClass()
method, equivalent to instanceof
in Java and is
in Dart:isKindOfClass() | Description | Example |
InvalidTokenReason | The token entered is not valid for the corresponding product | Parameterize "test123" as token in the SDK builder |
PermissionReason | You are missing some mandatory permission to run the SDK | Start DocumentDetector without camera permission granted |
NetworkReason | Internet connection failure | User was without internet during facematch in FaceAuthenticator |
ServerReason | When an SDK request receives a status code of failure | In theory, it shouldn't happen. If it does, let us know! |
StorageReason | There is no space on the user device's internal storage | When there is no space on the internal storage while capturing the document photo |
InvalidFaceReason | There is no face record for the given peopleId | When the user authenticates with a peopleId that has no face record |
You can customize the layout by creating an object of type
FaceAuthenticatorLayout
and passing it as a parameter to the FaceAuthenticatorBuilder
:let layout = FaceAuthenticatorLayout()
layout.changeMaskImages(
greenMask: UIImage(named: "my_green_mask"),
whiteMask: UIImage(named: "my_white_mask"),
redMask: UIImage(named: "my_red_mask"))
layout.changeSoundImages(soundOn: UIImage(named: "my_sound_on_image"),
soundOff: UIImage(named: "my_sound_off_image"))
layout.closeImage = UIImage(named: "my_close_image")
layout.buttonSize = CGFloat(50)
layout.buttonContentMode = .scaleAspectFill
let faceAuthenticatorConfiguration = FaceAuthenticatorBuilder(apiToken: "API_TOKEN")
.setLayout(layout: layout)
.build()
Last modified 4mo ago