Getting Started with the SDK
About CafSDK
This technical documentation covers the implementation of CafSDK for Flutter, detailing the configuration, initialization, execution of capture flows, and advanced customizations.
CafSDK is a unified SDK that integrates multiple modules for identity verification: Face Liveness (FL) and Document Detector (DD), executed sequentially with a unified configuration interface.
What is Face Liveness
Face Liveness is the module that validates the authenticity of a face captured by a photo application, ensuring that the image corresponds to a real person and not a spoofing attempt.
Technical characteristics:
URL configuration for authentication (
authBaseUrl) and liveness verification (livenessBaseUrl)Support for reverse proxy configuration with certificate pinning
Flags to enable screen capture and debug mode
Configurable retry attempts and face authentication execution
Support for multiple authentication providers
What is Document Detector
Document Detector is the module that enables the capture and processing of documents (e.g., ID card, social security card, passport, etc.).
Technical characteristics:
Configuration of a step-by-step flow defined by
CafDocumentDetectorFlowfor document captureSupport for multiple document types (RG, CNH, Passport, etc.)
Operational parameters, such as timeout, manual capture flags, and other settings
Possibility of using the camera for framing validations, or document file upload
Advanced customization options for UI, messages, and behavior
Example
Check out the example app for a complete implementation example.
Installation
Requirements
To use the CafSDK modules in Flutter, ensure that your project meets the minimum requirements:
Flutter
Flutter Version
3.3.0+
Dart
3.9.0+
Android
Android SDK API - minimum version (minSdk)
26
Android SDK API - compile version (compileSdk)
36+
Kotlin
1.8+
Gradle
8.0+
Android Gradle Plugin (AGP)
8.0+
iOS
iOS Deployment Target
13.0+
Xcode
14.0+
Swift
5.0+
Step 1: Install the SDK
Install the main SDK package:
Step 2: Configure Module Selection
Create a caf-modules-config.json file in your project root to specify which modules to include:
Note: If you omit this file, all modules are enabled by default and
iproov-liteis used as the default Face Liveness provider.
Set to true the modules you want to use in your application.
For a single provider, livenessProviders can be a string. Allowed values are iproov-lite, iproov-full, payface, and facetec. To use several providers, use an array (see the example below).
iProov and Protobuf
iproov-lite: use when your app targets Protobuf JavaLiteβthe usual choice for a smaller binary footprint on Android.iproov-full: use when you need Protobuf Java (full) together with iProov.
You can declare more than one provider by setting livenessProviders to an array when your integration requires it.
If you include the PayFace provider, you must also use iProov Lite (iproov-lite). PayFace is built against Protobuf JavaLite; mixing it with iproov-full causes Protobuf dependency conflicts at build time.
Set to true the modules you want to use in your application.
Fingerprint
The Fingerprint module is optional and is configured in caf-modules-config.json via the fingerprint property (boolean). It defaults to false, so you don't need to add the property unless you want to use it. To enable the module, explicitly set "fingerprint": true.
Requires a Face Liveness module. Fingerprint is collected as part of the liveness flow, so it is only bundled when faceLiveness or faceLivenessUI is also enabled. Setting "fingerprint": true without a liveness module enabled has no effect.
Important: Please contact CAF Support to request activation. If it is not enabled on our side, the SDK will not trigger the fingerprint library and no data will be sent, even if the property is set to true locally.
Step 3: Android Configuration
Add Maven Repositories
Configure the project's build.gradle.kts file (usually located at the root level):
Step 4: iOS Configuration
Navigate to the ios/ directory of your Flutter project and run:
This step is mandatory for iOS to correctly link the native modules and their required dependencies.
Always re-run
pod installwhenever native dependencies are added or updated.
Permissions
Android
For the modules to operate correctly, you must declare the following permissions in your AndroidManifest.xml:
For Face Liveness
android.permission.CAMERA
Allows access to the camera to capture images and perform face verification (liveness).
Mandatory
android.permission.INTERNET
Allows communication with authentication and verification services (HTTPS/WSS).
Mandatory
For Document Detector
android.permission.CAMERA
Allows access to the camera to capture document images.
Only for capture
android.permission.INTERNET
Allows captured images to be sent to servers for processing and validation.
Mandatory
android.permission.READ_EXTERNAL_STORAGE
Allows access to stored files and images for processing, if necessary.
Only for upload
iOS
For the SDK modules to function correctly, you must declare the following permissions in your Info.plist:
For Face Liveness:
NSCameraUsageDescription
Allows access to the camera to capture images and perform face verification (liveness).
Mandatory
Network access
Allows communication with authentication and verification services (HTTPS/WSS).
Mandatory
For Document Detector:
NSCameraUsageDescription
Allows access to the camera to capture document images.
Only for capture
Network access
Allows captured images to be sent to servers for processing and validation.
Mandatory
NSPhotoLibraryUsageDescription
Allows access to stored files and images for processing, if necessary.
Only for upload
Basic Implementation
Simple Example
Here's a basic implementation example:
Configuration
Language
Android
The language is automatically set according to the language configured on the device without any additional settings.
iOS
According to Apple's documentation, configuring Localizations and CFBundleLocalizations should be done in Xcode:
After these settings, the SDK will recognize the device's language.
Global Configuration
The CafSdk class serves as the central container for all configurations. This configuration defines the execution order of the modules and the visual identity.
Essential parameters:
mobileToken: Token that authenticates the request and ensures that only authorized clients start the flow
personId: Unique user identifier for which the flow will be executed
environment: Defines the execution environment (PROD, BETA, DEV)
presentationOrder: Defines the sequence in which the modules will be executed
enableSecurityModule: Enables or disables the security module. Optional, default is
true
Code example for creating the global configuration:
Module-Specific Configuration
Face Liveness Configuration
You can configure the Face Liveness module by creating a CafFaceLivenessConfiguration. When using the optional PayFace (Fortface) provider, use payFaceDebugMode to enable debug mode for that provider.
Document Detector Configuration
You can configure the Document Detector module by creating a CafDocumentDetectorConfiguration:
Event Handling
Ensure the JWT response is evaluated on the backend. This process must include validating the token's signature and verifying the isAlive and isMatch fields. Do not perform these validations on the client side.
The eventStream from the CafSdk class provides a typed Stream<CafResponse> generated during the execution of the capture flow. Each CafResponse has exactly one populated field, which indicates the event type:
loading
bool
Indicates the start of module processing
loaded
bool
Indicates that the module has been processed
success
CafSuccessResponse?
Upon successful completion; contains moduleName and signedResponse
error
CafErrorResponse?
A problem occurred during execution; contains type and description
failure
CafFailureResponse?
Indicates a Face Liveness failure; contains type, description, and response
log
CafLog?
Log messages with different levels; contains level (DEBUG, USAGE, INFO) and message
cancelled
bool
Indicates that the user or system interrupted the flow
Migration note (v2.0.0):
eventStreamnow emits typedCafResponseobjects instead of rawMappayloads. Replace anyevent['eventName']/event['response']access with the typed fields shown above.
Example of event handling:
Error Types (CafErrorType)
CAMERA_PERMISSION
Camera access denied
UNSUPPORTED_DEVICE
Unsupported device specs
NETWORK_EXCEPTION
Network connectivity issues
SERVER_EXCEPTION
Backend processing failure
TOKEN_EXCEPTION
Invalid/expired token
CAPTURE_ALREADY_ACTIVE_EXCEPTION
Concurrent capture session
UNEXPECTED_ERROR_EXCEPTION
Critical unrecoverable error
USER_TIMEOUT_EXCEPTION
Capture timeout exceeded
IMAGE_NOT_FOUND_EXCEPTION
Missing image data
TOO_MANY_REQUESTS_EXCEPTION
API rate limit exceeded
UNKNOWN_EXCEPTION
Unclassified error
LIBRARY_EXCEPTION
Low-level framework error
PERMISSION_EXCEPTION
Missing system permissions
INVALID_EXCEPTION
Invalid response received
SEQUENCE_INVALID
Invalid operation sequence
LIVENESS_EXCEPTION
Face liveness specific error
FINGERPRINT_EXCEPTION
Fingerprint related error
STORAGE_EXCEPTION
Storage access error
PROXY_EXCEPTION
Proxy configuration error
SECURITY_EXCEPTION
Security validation error
INVALID_RESPONSE_EXCEPTION
Invalid response payload received from a module
CAMERA_EXCEPTION
Camera initialization or runtime failure
FACE_AUTHENTICATION
Error during face authentication (executeFaceAuth)
BRIDGE_EXCEPTION
Native β Flutter bridge communication error
Failure Types (CafFailureType)
UNKNOWN
Generic failure
β
β
TOO_MUCH_MOVEMENT
Excessive head motion
β
β
TOO_BRIGHT
Over-illumination
β
β
TOO_DARK
Low light conditions
β
β
MISALIGNED_FACE
Face alignment failure
β
β
FACE_TOO_FAR
Face too distant
β
β
FACE_TOO_CLOSE
Face too close
β
β
SUNGLASSES
Eye-obscuring eyewear
β
β
OBSCURED_FACE
Partial face obstruction
β
β
EYES_CLOSED
Closed eyes during capture
β
β
MULTIPLE_FACES
Multiple faces detected
β οΈ
β οΈ
BACKGROUND_ISSUE
Unsuitable background
β
β
DEVICE_ISSUE
Incompatible device
β
β
EYEWEAR
Eyewear detected
β
β
FACE_NOT_FOUND
Face detection failure
β
β
FRAMES_BLURRY
Blurry frames detected
β
β
MOTION_ISSUE
Device motion error
β
β
LIGHTING_ISSUES
Poor lighting conditions
β
β
REJECTED
Transaction rejected
β
β
SYSTEM_ERROR
Internal system error
β
β
TIMEOUT
Session timeout
β
β
USER_NOT_FOUND
User lookup failure
β
β
DEVICE_RESTART
Device state error
β
β
PROCESSING_FAULT
Processing error
β
β
Document Types
Supported Documents (CafDocument)
RG_FRONT
Front side of the RG document, where the photo is located
RG_BACK
Back side of the RG document
RG_FULL
Open RG document, displaying both the front and back sides together
CNH_FRONT
Front side of the CNH document, where the photo is located
CNH_BACK
Back side of the CNH document
CNH_FULL
Open CNH document, displaying both the front and back sides together
CRLV
CRLV document
RNE_FRONT
Front side of the RNE or RNM document
RNE_BACK
Back side of the RNE or RNM document
CTPS_FRONT
Front side of the CTPS document, where the photo is located
CTPS_BACK
Back side of the CTPS document
PASSPORT
Passport document, displaying the photo and personal data
ANY
Allows submission of any type of document, including all those listed above or any other unclassified document
Supported File Formats (CafFileFormat)
PNG
image/png
JPG
image/jpg
JPEG
image/jpeg
PDF
application/pdf
HEIF
image/heif
HEIC
image/heic
Advanced Configuration
Face Liveness UI Configuration
When using the UI module, you can customize instruction screens:
Document Detector UI Configuration
Proxy Configuration
For Document Detector proxy settings:
Message Customization
Customize messages displayed during the capture flow:
Complete Implementation Example
Here's a complete example showing both Face Liveness UI and Document Detector UI:
ProGuard/R8 Rules
Add these ProGuard/R8 rules to your proguard-rules.pro file for Android:
Technical Support and Usage Tips
Technical Support If you have any questions or difficulties with the integration, contact Caf's technical support.
Usage Tips
Run tests: Perform tests on real devices to validate requirements and flow performance
Explore customizations: Use advanced customization options to tailor the flow to your project's needs
Monitor performance: Integrate monitoring tools to track logs and the flow's performance in production
Handle errors gracefully: Implement proper error handling for all possible error and failure scenarios
Test with different devices: Ensure compatibility across various device specifications and screen sizes
Release Notes
[email protected]
Release date
08-03-2026
Breaking change : The Fingerprint module is now optional and can be configured in caf-modules-config.json via the new fingerprint property (boolean). By default, fingerprint is set to false, meaning you do not need to add this property to the JSON unless you want to use it. To enable the module, you must explicitly add "fingerprint": true. Important: Fingerprint must also be enabled on Backoffice. If it is not enabled on Backoffice, the SDK will never call the fingerprint library and no data will be sent, even if the property is set to true locally.
Highlights
Optional Fingerprint module: Control the inclusion of the fingerprint feature directly from
caf-modules-config.json. It is disabled by default, ensuring you only include the dependency when strictly necessary.
Updates
New
fingerprintboolean field incaf-modules-config.jsonfor Android and iOS.
[email protected]
Release date
07-06-2026
Breaking change: The eventStream now emits a typed Stream<CafResponse> instead of a Stream<dynamic> with raw Map payloads. Update every listener: replace event['eventName'] / event['response'] with the typed fields β event.success, event.error, event.failure, event.log, event.loading, event.loaded, and event.cancelled. See Event Handling for the full migration example.
Highlights
More consistent error reporting: Errors occurring during flow initialization that relate to the SDK's internal integration are now emitted via the
errorevent asBRIDGE_EXCEPTION, so they can be handled the same way as any other SDK error.
Breaking Changes
Typed event stream:
CafSdk.eventStreamis nowStream<CafResponse>. Consumers must access the typed fields ofCafResponse(success,error,failure,log,loading,loaded,cancelled) instead of indexing aMap.Flattened module configuration classes: The per-module
...BuilderConfigurationwrappers were removed. Fields are now passed directly on the module configuration objects, and the UI configurations extend the base configuration instead of nesting it:CafFaceLivenessBuilderConfigurationremoved β pass fields directly onCafFaceLivenessConfiguration.CafDocumentDetectorBuilderConfigurationremoved β pass fields directly onCafDocumentDetectorConfiguration.CafFaceLivenessUIBuilderInstructionScreenConfigurationβCafFaceLivenessUIInstructionScreenConfiguration, and the fieldinstructionScreenConfigurationβinstructionScreen.CafDocumentDetectorUIBuilderInstructionScreenConfigurationβCafDocumentDetectorUIInstructionScreenConfiguration, and the fieldinstructionScreenConfigurationβinstructionScreen.CafDocumentDetectorUIBuilderDocumentSelectionScreenConfigurationβCafDocumentDetectorUIDocumentSelectionScreenConfiguration, and the fielddocumentSelectionScreenConfigurationβdocumentSelectionScreen.The SDK-level
CafSdkConfigurationis unchanged and still takesconfiguration: CafSdkBuilderConfiguration(...).
initializeCafSdkreturn type: changed fromFuture<bool?>toFuture<bool>.
Updates
Event name constants: Added the
CafSdkEventNameconstants (CafUnifiedEvent.*) for identifying emitted events.New
CafErrorTypevalues: AddedINVALID_RESPONSE_EXCEPTION,CAMERA_EXCEPTION,FACE_AUTHENTICATION, andBRIDGE_EXCEPTION. Note thatBRIDGE_EXCEPTIONreports errors that occur while initializing or starting the flow; listen for it on theerrorevent and handle it as part of your normal error handling.CafSuccessResponse:signedResponseis now typed asString?(previouslydynamic), andmoduleNameresolution is more resilient to native identifier variations.
Migration Guide β 1.x β 2.0.0
Three things changed for integrators: how you read events, how you build module configurations, and the return type of initializeCafSdk. The SDK-level CafSdkConfiguration (with CafSdkBuilderConfiguration) is unchanged.
1. Read events from the typed stream
2. Remove the module ...BuilderConfiguration wrapper
Pass the fields directly on the module configuration object.
3. Update the UI configurations (wrapper + renamed types and fields)
4. Rename type imports (if you imported the removed types)
CafFaceLivenessBuilderConfiguration
CafFaceLivenessConfiguration
CafDocumentDetectorBuilderConfiguration
CafDocumentDetectorConfiguration
CafFaceLivenessUIBuilderInstructionScreenConfiguration
CafFaceLivenessUIInstructionScreenConfiguration
CafDocumentDetectorUIBuilderInstructionScreenConfiguration
CafDocumentDetectorUIInstructionScreenConfiguration
CafDocumentDetectorUIBuilderDocumentSelectionScreenConfiguration
CafDocumentDetectorUIDocumentSelectionScreenConfiguration
5. Update the initializeCafSdk return type
initializeCafSdk now returns Future<bool> instead of Future<bool?>. Remove any null checks on the awaited result.
[email protected]
Release date
05-25-2026
Updates
Payface Liveness Provider (Android): Update version from
1.18.2to1.19.2.Payface Liveness Provider (iOS): Update version from
1.5.2to1.8.2.
Fixes
FaceLiveness
Infinite loading error occurs when the SDK returns an error.
First initialization not working when using
Payfaceprovider.
[email protected]
Release date
05-08-2026
Fixes
DocumentDetector: Fixed behavior when handling RG (Brazilian National Identity Card) with the digital document option.
[email protected]
Release date
04-13-2026
Breaking change : Face Liveness providers can now be configured in caf-modules-config.json via livenessProviders (string or array). When provided, it must list the chosen provider(s). Do not use iproov-lite and iproov-full togetherβiproov-full uses a different version of Protobuf, and combining them will cause duplicate class errors at build time. PayFace requires iproov-lite (Protobuf JavaLite); pairing PayFace with iproov-full causes build-time Protobuf conflicts. If omitted, the SDK defaults to iproov-lite on both platforms. An empty or invalid value causes a build error on Android; on iOS, an empty value also falls back to iproov-lite, but an invalid value causes a build failure. See Step 2: Configure Module Selection for details.
Highlights
Configurable Face Liveness providers: Choose
iproov-lite,iproov-full,payface, and/orfacetecfromcaf-modules-config.jsoninstead of relying on implicit native defaults.
Updates
Liveness provider configuration:
New
livenessProvidersfield incaf-modules-config.jsonfor Android and iOS.Documented Protobuf JavaLite vs Protobuf Java mapping for
iproov-litevsiproov-full.Clarified multi-provider setups using an array, and the PayFace + iProov Lite requirement.
iProov Liveness Provider: Documentation and defaults updated to reflect the new provider selection model.
Android ProGuard / R8: If R8 reports missing classes for lint stubs shipped with the SDK, add the following to
proguard-rules.pro(also listed under ProGuard/R8 Rules):
[email protected]
Release date
02-09-2026
Versions earlier than 1.2.0 will result iProov Liveness to become inoperable as of March 12, 2026. To ensure proper functionality and service continuity, please use version 1.2.0 or later.
Highlights
Updated Liveness Provider: Critical update to the iProov provider version for improved stability
Updates
iProov Liveness Provider: Updated the internal iProov provider version.
[email protected]
Release date
02-09-2026
Highlights
New Security Module: Introduction of
CafSecuritymodule for security validationsPayFace Integration: Added support for PayFace (Fortface) as an optional Face Liveness provider
Stability Improvements: Major crash fixes and stability improvements for the Document Detector module
Features
CafSecurity Module:
Added a new module specifically for security validations
Configuration: Added
enableSecurityModuleflag inCafSdkConfiguration(default value:true)
PayFace (Fortface) Integration:
Optional Face Liveness provider integration
Configuration: New property
payFaceDebugModeinCafFaceLivenessConfigurationto enable debug mode for the PayFace provider
Fixes
DocumentDetector:
Activity Lifecycle: Resolved multiple crashes related to activity lifecycle management (initialization, pause, and resume states)
Camera Lifecycle: Improved camera resource management and thread lifecycle to prevent crashes during SDK shutdown
UI Components: Resolved theme compatibility issues and fragment transaction exceptions
Network Requests: Corrected response body handling to prevent errors when reading network responses
Data Access: Improved cursor initialization and validation before accessing database data
ANR Prevention: Optimized document controller instance checks to prevent "Application Not Responding" issues
General: Internal improvements and stability corrections
FaceLiveness:
Sessions: Fixed session creation errors
UI: Fixed color tint on remote images in the Instructions screen
Updates
Build Configuration:
ProGuard Rules: Added necessary ProGuard rules for PayFace integration
[email protected]
Release date
03-09-2026
Updates
Updated iProov Liveness Provider: Update iProov provider version.
Updated iOS minimum deployment target: Updated to
15.0.
Fixes
DocumentDetector
Fixed crashes in Document Detector module: Resolved multiple crashes related to activity lifecycle management, including initialization, pause, and resume states.
Fixed crashes related to camera lifecycle: Improved camera resource management and thread lifecycle to prevent crashes during SDK shutdown and state transitions.
Fixed crashes in UI components: Resolved theme compatibility issues and fragment transaction exceptions to ensure proper UI behavior.
Fixed crashes in network requests: Corrected response body handling to prevent errors when reading network responses.
Fixed crashes in data access: Improved cursor initialization and validation before accessing database data.
Fixed ANR in Document Controller: Optimized document controller instance checks to prevent application not responding issues.
Internal improvements and corrections: Additional stability enhancements and bug fixes.
[email protected]
Release date
10-27-2025
Highlights
First Flutter SDK Release: Complete Flutter implementation of the CAF SDK for identity verification
Unified SDK: Single package containing all CAF modules (Face Liveness and Document Detector) with both core and UI variants
Flutter-Native Integration: Seamless integration with Flutter's widget system and state management
Cross-Platform Support: Full support for both Android and iOS platforms
Type-Safe Configuration: Strongly typed Dart configuration classes for better development experience
Features
Module Configuration System:
caf-modules-config.json: Configuration file in project root to specify which modules to includeAvailable modules:
documentDetector: Enable/disable Document Detector modulefaceLiveness: Enable/disable Face Liveness moduledocumentDetectorUI: Enable/disable Document Detector UI modulefaceLivenessUI: Enable/disable Face Liveness UI module
Example configuration:
Core SDK Features:
CafSdk Class: Main SDK class for initialization and configuration
Event Stream: Real-time event handling through Dart streams
Module Management: Sequential execution of modules with configurable presentation order
Error Handling: Comprehensive error types and failure handling
Configuration Builder: Type-safe configuration using builder pattern
Face Liveness Module:
Core Module:
CafFaceLivenessConfigurationfor programmatic controlUI Module:
CafFaceLivenessUIConfigurationwith customizable instruction screensFeatures: Authentication URLs, certificate pinning, debug mode, retry attempts
Customization: Instruction screens with images, titles, descriptions, and steps
Document Detector Module:
Core Module:
CafDocumentDetectorConfigurationfor programmatic controlUI Module:
CafDocumentDetectorUIConfigurationwith full UI customizationDocument Types: Support for RG, CNH, Passport, RNE, CTPS, and more
Upload Support: File upload with compression, format control, and size limits
Proxy Configuration: Support for proxy servers with authentication
Message Customization: Customizable user messages throughout the flow
Advanced Configuration:
Color Theming: Complete UI color customization through
CafColorConfigurationSecurity Settings: Development flags, debug mode, and security controls
Flow Control: Manual capture, timeouts, retry attempts, and popup controls
Instruction Screens: Customizable instruction screens for both modules
Technical Implementation
Flutter Integration:
Method Channels: Native communication through Flutter's method channel system
Stream-Based Events: Real-time event handling using Dart streams
State Management: Proper lifecycle management with
StatefulWidgetsupportError Handling: Comprehensive error handling with typed exceptions
Platform Support:
Android: Full support with ProGuard/R8 rules and Maven repository configuration
iOS: Complete integration with CocoaPods and native iOS modules
Permissions: Proper permission handling for camera and network access
Performance:
Selective Module Loading: Only load enabled modules to optimize bundle size
Memory Management: Proper resource cleanup and memory management
Network Optimization: Efficient network communication with retry mechanisms
Installation and Setup
Package Installation: Simple installation via
flutter pub add caf_sdkModule Configuration: Easy module selection through JSON configuration file
Platform Setup: Clear instructions for Android and iOS platform configuration
Permission Management: Comprehensive permission setup for both platforms
Documentation
Complete Examples: Full implementation examples for both basic and advanced usage
Configuration Guide: Detailed configuration options for all modules
Event Handling: Comprehensive event handling examples and patterns
Error Reference: Complete error types and failure scenarios documentation
Breaking Changes
First Release: This is the first release of the Flutter SDK, so there are no breaking changes from previous versions.
Known Issues
iOS Simulator: Some features may not work properly in iOS Simulator due to camera limitations
Android Emulator: Camera-dependent features require physical devices for testing
Network Requirements: All modules require internet connectivity for proper operation
Last updated

