Comment on page
PassiveFaceLiveness(Deprecated)
When using our plugin, please make sure that you agree with our Privacy Policy and our Terms and Conditions of Use.
Minimum configuration | Version |
Flutter | 1.12+ |
Dart | 2.12+ |
Minimum Android API | 21+ |
Compile SDK Version | 33 |
iOS | 11.0+ |
In the file
ROOT_PROJECT/android/app/build.gradle
, add:android {
...
dataBinding.enabled = true
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
//To perform layout customization from the SDK import the following libraries
dependencies {
implementation "androidx.camera:camera-view:1.2.1"
//native Android SDK that the plugin implements
implementation 'com.combateafraude.sdk:passive-face-liveness:6.0.0-rc06'
//design libraries that you will use in your layout (these are used in our example template for customization)
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
}
In the
ROOT_PROJECT/ios/Podfile
, add to the end of the file:source 'https://github.com/combateafraude/iOS.git'
source 'https://cdn.cocoapods.org/' # or 'https://github.com/CocoaPods/Specs' if CDN is down
Finally, add the camera permission to the file
ROOT_PROJECT/ios/Runner/Info.plist
:<key>NSCameraUsageDescription</key>
<string>To capture the selfie</string>
To enable text and voice in Portuguese, in your project, in the ROOTPROJECT/ios directory, open the .xcworkspace file in Xcode and add in Project > Info > Localizations the language Portuguese (Brazil).
Add the plugin to your
ROOT_PROJECT/pubspec.yaml
file:
dependencies:
passive_face_liveness:
git:
url: https://github.com/combateafraude/Flutter.git
ref: passive-face-liveness-v4.30.0
dependencies:
passive_face_liveness:
git:
url: https://github.com/combateafraude/Flutter.git
ref: passive-face-liveness-v5.0.0-rc06
PassiveFaceLiveness passiveFaceLiveness = new PassiveFaceLiveness(mobileToken: mobileToken);
// Other customization parameters
PassiveFaceLivenessResult passiveFaceLivenessResult = await passiveFaceLiveness.start();
if (passiveFaceLivenessResult is PassiveFaceLivenessSuccess) {
// The SDK was successfully closed and the selfie was captured
} else if (passiveFaceLivenessResult is PassiveFaceLivenessFailure) {
// The SDK was closed due to some failure and the selfie was not captured
} else {
// The user simply closed the SDK, with no result
}
We are constantly taking actions to make the product more and more secure, mitigating a number of attacks observed in the capture process and, consequently, reducing as many possible identity frauds as possible. The SDK has some blocks that may prevent its execution in certain contexts. To disable them, you can use the methods as shown in the example below:
PassiveFaceLivenessAndroidSettings androidSettings =
PassiveFaceLivenessAndroidSettings(
emulatorSettings: true,
rootSettings: true,
useDeveloperMode: true,
useAdb: true,
useDebug: true,
);
passiveFaceLiveness.setAndroidSettings(androidSettings);
Attention! Disabling security validations is recommended for test environments only. For publishing your application in production, we recommend using the default settings.
PassiveFaceLiveness |
.setPeopleId(String peopleId) CPF of the user who is using the plugin to be used for fraud detection via analytics |
.setPersonName(String personName) Binds a proof-of-life attempt to a name |
.setPersonCPF(String personCPF) Binds a proof-of-life attempt to a cpf |
.setAnalyticsSettings(bool useAnalytics) Enables/disables data collection for maximizing anti-fraud information. Default is true |
.setAudioSettings(bool enable, String audioResIdName) Enables/disables sounds. Allows you to customize the audio used by the SDK. If you want to change the SDK's audio, add the audio file in ROOT_PROJECT/android/app/src/main/res/raw/ with the desired name below and parameterize it |
.setNetworkSettings(int requestTimeout)
Changes the default network settings. The default is 60 seconds |
.setPreviewSettings(PreviewSettings previewSettings) Preview for photo quality check |
.setCaptureMode(VideoCapture videoCapture, ImageCapture imageCapture) Sets the capture settings |
.setGetImageUrlExpireTime(String expireTime) Sets how long the image URL will last on the server until it is expired. Expect to receive a time interval between "30m" to "30d". The default is 3h |
.setMessageSettings(MessageSettings messageSettings) Allows you to customize the messages displayed in the "status" balloon during the capture and analysis process |
.setCurrentStepDoneDelay(bool showDelay, int delay) Delay the activity after each step is finished. This method can be used to display a success message on the screen itself after the capture, for example. Default is false |
.setAndroidSettings(PassiveFaceLivenessAndroidSettings androidSettings) Customizations only applied on Android |
.setIosSettings(PassiveFaceLivenessIosSettings iosSettings) Customizations only applied on iOS |
.setEyesClosedSettings(bool enable, double threshold) Lets you customize the eyes-open validation in the SDK |
.setCaptureProcessingErrorMessage(@NonNull @StringRes Integer message) Allows you to customize the message displayed when a processing problem or error occurs in the API response. |
.setStage(String stage) Allows you to choose the environment in wich the SDK will run (production or beta). The expected String values are: "PROD" and "BETA". This setting is not mandatory, by default the SDK will use the production environment. |
Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.
ImageCapture constructor |
bool use Enables/disables the capture of a frame. Default is true |
int beforePictureMillis Duration in milliseconds between the first detection of the face and the actual capture of the picture. The default is 0 ms |
int afterPictureMillis Duration in milliseconds between capturing the picture and sending it to the server to keep the face and sensors valid. The default is 2000 ms |
VideoCapture constructor |
bool use Enables/disables video capture. Default is false |
int time This sets the time of the video that will be captured. The default is 3s |
PreviewSettings |
bool show Enable/Disable preview |
String title Title |
String subTitle Subtitle |
String confirmLabel Text of the confirmation button |
String retryLabel Text of the retry button |
Example of use
PreviewSettings previewSettings = new PreviewSettings(
show: true,
title: "Is the photo good?",
subTitle: "See if the photo is sharp",
confirmLabel: "Yes, it's good!",
retryLabel: "Take it again");
passiveFaceLiveness.setPreviewSettings(previewSettings);
MessageSettings |
String stepName Default: "Registro Facial" |
String holdItMessage Default: "Segure assim" |
String faceNotFoundMessage Default: "Não encontramos nenhum rosto" |
String faceTooFarMessage Default: "Aproxime o rosto" |
String faceTooCloseMessage (Android only)Default: "Afaste o rosto" |
String faceNotFittedMessage Default: "Encaixe seu rosto" |
String multipleFaceDetectedMessage Default: "Mais de um rosto detectado" |
String verifyingLivenessMessage Default: "Verificando selfie…" |
String invalidFaceMessage Default: "Ops, rosto inválido. Por favor, tente novamente" |
String? sensorStabilityMessage Default: "Mantenha o celular parado" |
String? captureProcessingErrorMessage Default: "Ops, tivemos um problema ao processar sua imagem. Tente novamente." |
String multipleFaceDetectedMessage Default: "Mais de um rosto detectado" |
String? sensorOrientationMessage (Android only)Default: "Celular não está na vertical" |
String eyesClosedMessage (Android only)Default: "Seus olhos estão fechados" |
String notCenterXMessage (Android only)Default: "Centralize seu rosto na vertical" |
String notCenterYMessage (Android only)Default: "Centralize seu rosto na horizontal" |
String notCenterZMessage (Android only)Default: "Seu rosto não está ajustado à máscara" |
Example of use
MessageSettings messageSettings = new MessageSettings(
stepName: "Example message",
faceNotFoundMessage: "Example message",
faceTooFarMessage: "Example message",
faceTooCloseMessage: "Example message",
faceNotFittedMessage: "Example message",
multipleFaceDetectedMessage: "Example message",
verifyingLivenessMessage: "Example message",
holdItMessage: "Example message",
invalidFaceMessage: "Example message");
passiveFaceLiveness.setMessageSettings(messageSettings);
PassiveFaceLivenessAndroidSettings constructor |
PassiveFaceLivenessCustomizationAndroid customization Customization of the Android layout of the activity |
SensorSettingsAndroid sensorSettings Customization of the capture sensor settings |
int manualCaptureTime Changes the time for the display of the manual capturing button. The default is 20000 milliseconds |
bool enableSwitchCameraButton Allows you to enable or disable the camera flip button. Default is True |
bool enableGoogleServices Allows you to enable/disable SDK features that consume GoogleServices in the SDK, we do not recommend disabling the services because of security loss. Default is True |
bool emulatorSettings Allows you to enable/disable the use of emulated devices in the SDK. We recommend disabling the use of emulators for security reasons. Default is False |
bool rootSettings Allows you to enable/disable the use of root devices in the SDK. We recommend disabling the use of these devices for security reasons. Default is False |
bool useDeveloperMode Allows you to enable/disable the use of devices with Android developer mode enabled. We recommend disabling the use of these devices for security reasons. Default is False |
bool useAdb Allows you to enable/disable the use of the Android Debug Bridge (ADB) debug mode. We recommend disabling the use of these devices for security reasons. Default is False |
bool enableBrightnessIncrease Enables/disables device brightness increment on opening the SDK |
PassiveFaceLivenessCustomizationAndroid constructor |
String styleResIdName Name of the style resource that defines the colors of the SDK. For example, if you want to change the SDK colors, create a style in ROOT_PROJECT/android/app/src/main/res/values/styles.xml with the name R.style.my_custom_style following the template and parameterize "my_custom_style". |
String layoutResIdName Name of the layout resource that will replace the default SDK layout. For example, if you want to change the SDK layout, create a layout in ROOT_PROJECT/android/app/src/main/res/layout/my_custom_layout.xml following the template and parameterize "my_custom_layout". Check the import libraries mentioned here |
String greenMaskResIdName Name of the drawable resource to replace the default green mask. If you are going to use this parameter, use a mask with the same cutting area, it is important for the detection algorithm. For example, save the mask image in ROOT_PROJECT/android/app/src/main/res/drawable/my_custom_green_mask.png and parameterize "my_custom_green_mask". |
String redMaskResIdName Name of the drawable resource to replace the default red mask. If you are going to use this parameter, use a mask with the same cutting area, it is important for the detection algorithm. For example, save the mask image in ROOT_PROJECT/android/app/src/main/res/drawable/my_custom_red_mask.png and parameterize "my_custom_red_mask". |
String whiteMaskResIdName Name of the drawable resource to replace the default white mask. If you are going to use this parameter, use a mask with the same cutting area, it is important for the detection algorithm. For example, save the mask image in ROOT_PROJECT/android/app/src/main/res/drawable/my_custom_white_mask.png and parameterize "my_custom_white_mask". |
MaskType maskType Defines the type of mask used in the captures. There are two types: MaskType.DEFAULT , with the dotted pattern, and MaskType.NONE , which removes the mask completely. The default is MaskType.DEFAULT |
SensorSettingsAndroid constructor |
SensorStabilitySettingsAndroid sensorStabilitySettings Stability sensor settings to be applied in all SDK steps |
sensorOrientationAndroid sensorOrientationAndroid Orientation sensor settings to be applied in all SDK steps |
SensorStabilitySettingsAndroid constructor |
int stabilityStabledMillis How many milliseconds the mobile must stay at the correct threshold to be considered stable. The default is 1500 ms |
double stabilityThreshold Stable/unstable threshold, in m/s² variation between the last two sensor collections. The default is 0.7 m/s². |
SensorOrientationAndroid constructor |
double stabilityThreshold Stable/unstable threshold, in m/s² variation between the last two sensor collections. The default is 4 m/s². |
PassiveFaceLivenessIosSettings constructor |
PassiveFaceLivenessCustomizationIos customization SDK visual customization |
int beforePictureMillis Duration in milliseconds between the first detection of the face and the actual capture of the picture |
SensorStabilitySettingsIos sensorStability Stability sensor settings to be applied in the SDK |
bool enableManualCapture Enables manual capture mode |
double timeEnableManualCapture Sets time (in seconds) to display manual capture button |
double compressionQuality Allows you to set the quality in the compression process. By default all captures are compressed. The method expects values between 0 and 1.0 as a parameter, 1.0 being the best quality compression (recommended).The default is 1.0 |
String resolution Allows setting the capture resolution. The method takes as parameter a String IosResolution (default is hd1280x720), which has the following options: |
Resolution | Description |
low | Specifies appropriate capture settings for output video and audio bit rates suitable for 3G sharing |
medium | Specifies the appropriate capture settings for the output video and audio bitrates suitable for sharing over WiFi |
high | Specifies appropriate capture settings for high-quality video and audio output |
photo | Specifies appropriate capture settings for high-resolution photo quality output |
inputPriority | Specifies appropriate capture settings for high-resolution photo quality output |
hd1280x720 | Specifies the appropriate capture settings for video output at 720p quality (1280 x 720 pixels) |
hd1920x1080 | Capture settings suitable for 1080p (1920 x 1080 pixels) quality video output |
hd4K3840x2160 | Capture settings suitable for 2160p (3840 x 2160 pixels) quality video output |
PassiveFaceLivenessCustomizationIos constructor |
String? colorHex The SDK's theme color. For example, if you want to use the color black, use "#000000". |
String? greenMaskImageName Name of the image to replace the default green mask. Remember to add the image in Assets Catalog Document in your XCode project |
String? whiteMaskImageName Name of the image to replace the default white mask. Remember to add the image in Assets Catalog Document in your XCode project |
String? redMaskImageName Name of the image to replace the default red mask. Remember to add the image in Assets Catalog Document in your XCode project |
String? closeImageName Name of the image to replace the close button in the SDK. Remember to add the image in Assets Catalog Document in your XCode project |
bool? showStepLabel Flag indicating whether to show the label of the current step |
bool? showStatusLabel Flag indicating whether to show the current status label |
double? buttonSize Value that sets the size of the "close" button in the SDK |
String? buttonContentMode Attribute that defines the content mode of the "close" button in the SDK. Choose from these values. |
SensorStabilitySettingsIos constructor |
String message String to be shown when the cell phone is not stable |
double stabilityThreshold Lower threshold between stable/unstable, in m/s² variation between the last two sensor collections. The default is 0.3 m/s². |
The PassiveFaceLiveness return object is of abstract type
PassiveFaceLivenessResult
. It can be an instance of PassiveFaceLivenessSuccess
, PassiveFaceLivenessFailure
, or PassiveFaceLivenessClosed
.Field | |
String imagePath Full address of the image on the device | |
String capturePath Full address of the video on the device. If the capture format is not video, the return is null | |
String imageUrl URL of the image temporarily stored in the CAF servers | |
String signedResponse Signed response from the CAF server that confirmed that the captured selfie has a real face (not a photo or video). 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 interception of the request. If it is broken, there is a strong indication of request interception | |
String trackingId 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 | Will be null if the user sets useAnalytics = false or the analytics calls do not work |
Field |
String message Friendly message explaining why the SDK failed |
String type Type of fault that shut down the SDK |
The existing fault types are:
InvalidTokenReason
: when the token entered is invalid. It should not occur in a production environment;PermissionReason
: when some mandatory permission was not granted by the user. It will only occur in a production environment if your app does not ask the user or the user manually disables it before starting;NetworkReason
: server connection failure. It will occur in production if the user's device is not connected to the Internet;ServerReason
: failure in some request to our servers.SecurityReason
: when the device is not safe to run the SDK.StorageReason
: when the device does not have enough space to capture a photo. This can happen in production;LibraryReason
: when some internal failure made it impossible to run the SDK. It may occur due to configuration errors in the project, and should not occur in production;
Customizing iOS view
For iOS customization, it is required that the Flutter plugins are added locally to the project. The customization is performed natively with the ViewCode approach.
Last modified 5mo ago