File upload and QR management - Capture
This component requires a minimum iOS 14 version
Introduction
File upload and the reading and generation of QR Codes are performed with the Capture Component.
This component allows document upload by taking a photo with the device camera or from the gallery. FileUploader, QR Reader and QR Generator use the KMP Widget FPHICaptureWidget (it has no native UI of its own). Its main features are:
Document upload via camera or gallery.
QR Code reading.
QR Code generation.
In the Simplified Launch the steps required for the basic Integration of the SDK are detailed. This section adds the information for the launch of this component.
Dependencies
To avoid conflicts and compatibility issues, if you want to install the component in a project that contains an old Version of the Facephi libraries (Widgets), these must be completely removed before installing the components of the SDKMobile.
CocoaPods
Currently, Facephi libraries are distributed remotely through different dependency managers, in this case CocoaPods. The dependencies mandatory that must have been installed beforehand (by adding them to the project's Podfile) are:
pod 'FPHISDKMainComponent', '~> $VERSION'To install the Capture component, the following entry must be included in the application's Podfile:
pod 'FPHISDKCaptureComponent', '~> $VERSION'SPM
The mandatory dependencies that must have been installed beforehand are:
To install the SelphID component, it must be included in the project's modules:
Available controllers
Controller
Description
FileUploaderController
Controller for document capture
QrReaderController
Controller for QR capture
QrGeneratorController
Controller for QR generation
Simplified Launch
Once the SDK has been started and a new operation has been created, the component can be launched. Any of its controllers can be used to execute its functionality.
Document capture launch:
QR capture launch:
QR generation launch:
Basic configuration
For the component capture and QR capture controllers, the configuration can be generated with the default parameters. For QR generation, the text to be used will be needed:
Result reception
The launch will return the information in SdkResult format.
errorType
finishStatus
data
Error handling
Errors will be returned as a 'CaptureError' object.
List of errors:
CAP_ACTIVITY_RESULT_MSG_ERROR: The result returned by the activity is incorrect or does not contain the necessary information to continue.
CAP_APPLICATION_CONTEXT_ERROR: The required application context is null or invalid, preventing the capture module from being initialized correctly.
CAP_CAMERA_ERROR: An internal error related to the device camera has occurred (failure to open, Initialization, or capture).
CAP_CAMERA_PERMISSION_DENIED: The user has denied the permissions required to access the camera.
CAP_CANCEL_BY_USER: The user has manually canceled the capture process.
CAP_CANCEL_LAUNCH: The process has been generally canceled by the SDK or by an external action.
CAP_COMPONENT_LICENSE_ERROR: The component License is not valid, has expired, or does not match the required configuration.
CAP_EMPTY_LICENSE: The License string is empty or has not been provided.
CAP_FETCH_DATA_ERROR: An error occurred while fetching or processing the data required to execute the Flow. (Includes additional information in the field
error.)CAP_FLOW_ERROR: An internal error occurred during the execution of the capture Flow. (Includes additional information in the field
error.)CAP_INITIALIZATION_ERROR: Error while initializing the necessary SDK components. (Includes detailed information in the field
error.)CAP_FILE_UPLOADER_CAPTURE_ERROR: Error during the process of uploading the files generated in the capture.
CAP_MANAGER_NOT_INITIALIZED: The managers required to execute the process have not been initialized correctly.
CAP_NO_DATA_ERROR: The required input data are null, nonexistent, or insufficient to continue the process.
CAP_OPERATION_NOT_CREATED: It was not possible to create or retrieve an active operation required to continue. (Includes detailed information in the field
error.)CAP_QR_CAPTURE_ERROR: Error during the capture or reading of the QR Code.
CAP_QR_GENERATION_ERROR: Error while generating the requested QR Code.
CAP_TIMEOUT: The maximum allowed time has been reached in one of the phases of the process.
CAP_FLOW_VIDEO_RECORDING_ERROR: Error during video recording within the established Flow.
CAP_FLOW_TRACKING_ERROR: Error while performing the Tracking required to complete the capture Flow.
Successful result reception - data
Result reception of document capture
In the SdkResult.Success section - data, we will have the class FileUploaderResult.
The fields returned in the result are as follows:
capturedDocumentList
List of captured files. They can be images or PDFs. The returned fields for each one are:
mimeType
timestampMillis
content: FileContent -> determines whether it is an image or a PDF document. If it is an image, it also indicates whether it was captured with the camera or from the gallery.
For example, to read the first element of the array:
Result reception of QR capture
In the SdkResult.Success section - data, we will have the class QrResult.
The fields returned in the result are as follows:
qrText
Text obtained from the QR Code
Result reception of QR generation
In the SdkResult.Success section - data, we will have an SdkImage with the created QR Code.
Advanced information
This section expands on the component information.
Advanced component configuration
Document capture configuration
To launch the current component, an object must be created FileUploaderConfigurationData which will be the configuration of the component controller.
Below are detailed all the fields that are part of this class.
vibrationEnabled: Indicates vibration activation when the Widget completes successfully.extractionTimeout: Sets the maximum time in which capture can be performed.showDiagnostic: Show diagnostic screens at the end of the process.showPreviousTip: Displays a screen before starting capture with information about the process to be carried out and a button to start it.maxScannedDocs: Maximum number of documents that can be capturedallowGallery: Gallery access is enabled for obtaining images or PDFsonlyGalleryMode: Opens the Flow directly in gallery mode, without showing the camera capture. By defaulttrue.maxGalleryImageSizeKb: Maximum size allowed for images selected from the gallery, in KB. By default2048. If an image exceeds this limit, the component returnsCAP_IMAGE_TOO_LARGE.
QR capture configuration
To launch the current component, an object must be created QrCaptureConfigurationData which will be the configuration of the component controller.
Below are detailed all the fields that are part of this class.
vibrationEnabled: Indicates vibration activation when the Widget completes successfully.extractionTimeout: Sets the maximum time in which capture can be performed.showDiagnostic: Show diagnostic screens at the end of the process.showPreviousTip: Displays a screen before starting capture with information about the process to be carried out and a button to start it.showTutorial: Indicates whether the component enables the tutorial screen. This view intuitively explains how capture is performed.cameraShape: Allows you to choose between a square and a round mask.
Component customization
Apart from the changes that can be made at SDK level (which are explained in the document of SDK customization), this particular component allows its interface to be modified.
Texts
The texts can be customized by overriding the value of the following keys in a Localizable.strings. The keys that contain the suffix _alt are the literals used in the accessibility labels needed for the functionality of VoiceOver.
In this way, if you want to modify for example the text “Start” of the key capture_widget_tip_button for the language es, you will need to go to the file Localizable.strings in the folder es.lproj if it exists (if not, it must be created) and there, add:
"capture_widget_tip_button"="Start";
If a message is not specified in the language file, it will be filled with the default message.
Animations
If you want to modify the SDK animations (lottie), you should include the animations with the same name in the app's res/raw/ folder.
Last updated