SelphID Component
1. Introductionβ
The Component addressed in the current document is name SelphID Component. This is responsible for capturing documents and the subsequent extraction and analysis of the data obtained from them. Its main functionalities are the following:
-
Internal camera management.
-
Permissions management.
-
Assists in the processes of capturing the front and back of the document.
-
Extraction of the information contained in the document.
-
Obtaining the images of the back and reverse of the document, as well as other images included in the document: user's face, user's signature,...
-
High level of configuration: different countries, languages, types of documents...
1.2 Plugin versionβ
The current plugin version can be checked as follows:
- Look for the pubspec.yaml file at the root of the plugin.
- The KEY/TAG version indicates the version.
2. Component integrationβ
βΉοΈ Before integrating this component, it is recommended to read the documentation related to Core Component and follow the instructions indicated in said document.
This section will explain step by step how to integrate the current component into an existing project.
For this section, the following values will be considered:
- <%APPLICATION_PATH%> - Path to the root of the application (example: /folder/example)
- <%PLUGIN_CORE_PATH%> - Path to the root of the Core plugin, which is required (example:/folder/sdk-core)
- <%PLUGIN_SELPHID_PATH%> - Path to the root of the current plugin (example /folder/sdk-selphid)
2.1. Plugin installation: Commonβ
The plugin allows execution on Android and iOS platforms. This section explains the common steps to all platforms. To install the plugin, the following steps must be adopted:
-
Make sure Flutter is installed.
-
Access APPLICATION_PATH at a terminal and run:
dart pub token add "https://facephicorp.jfrog.io/artifactory/api/pub/pub-pro-fphi"
It is possible that you have to type the credential token after the previous command.
- Access to the <APPLICATION_PATH> and add int he pubspec.yaml file:
fphi_sdkmobile_selphid:
hosted:
name: fphi_sdkmobile_selphi
url: https://facephicorp.jfrog.io/artifactory/api/pub/pub-pro-fphi/
version: ^2.6.0
After running the above steps, projects generated in the Android and iOS folders can be opened, compiled, and debugged using Android Studio and XCode respectively.
2.2 Plugin installation: iOSβ
2.2.1 Project configurationβ
For the iOS version, when adding our plugin to the final application, the following points must be previously taken into account:
- Add camera permissions: To use the widget, you need to enable the camera permission in the application's info.plist file (included within the project in the ios folder). You will need to edit the file with a text editor and add the following key/value pair:
<key> NSCameraUsageDescription </key>
<string>$(PRODUCT_NAME) uses the camera</string>
2.2.2 Podfile Updateβ
In the project podfile it will be necessary to add the information from the private repository (see section 2.1). To do this, the following lines must be added at the beginning of the file:
platform :ios, '13.0' //MIN VERSION
plugin 'cocoapods-art', :sources => ['cocoa-pro-fphi']
source 'https://cdn.cocoapods.org/'
βΉοΈ To know more about the configuration and use of Cocoapods Artifactory, it is necessary to access the following document of Core Component.
2.2.3 Possible issuesβ
If environmental problems occur or the plugin is not updated after making new changes (for example, problems occurred due to the bundle not being generated correctly, or the libraries not being updated to the correct versions), it is recommended to execute the following sequence of instructions after launching the plugin:
-
Open the application's ios folder at a terminal.
-
Run the following command:
pod deintegrate
-
Remove the Podfile.lock
-
Run the following command (or open the project with Xcode and run it):
pod install --repo-update
2.3 Plugin installation: Androidβ
2.3.0 Set Android SDK versionβ
For Android, the minimum SDK version required by our native libraries is 24, so if your app has a Minimum SDK defined less than this, it will need to be modified to avoid a compile error. To do this, access the application's build.gradle file (located in the android folder) and modify the following parameter:
buildscript {
ext {
minSdkVersion = 24
}
}
3. Component configurationβ
The current component contains a number of Dart methods and interfaces contained within the fphi_sdkmobile_selphid/fphi_sdkmobile_selphid_configuration.dart file. ** In this file you can find the necessary API for the communication between the application and the native functionality of the component. It is then explained what each one of those listed is for and the other properties that affect the operation of the component.
The following is the SelphIDConfiguration class, which allows you to configure the SelphID component:
class SelphIDConfiguration
{
bool mWizardMode;
bool mDebug;
bool mShowResultAfterCapture;
bool mShowTutorial;
bool mTutorialOnly;
SelphIDScanMode mScanMode;
SelphIDDocumentSide mDocumentSide;
String mSpecificData;
bool mFullscreen;
double mTokenImageQuality;
SelphIDDocumentType mDocumentType;
SelphIDTimeout mTimeout;
bool mGenerateRawImages;
SelphIDCompressFormat mCompressFormat;
double mJPGQuality;
String mTranslationsContent;
String mViewsContent;
String mDocumentModels;
bool? mShowDiagnostic;
}
Then, all the properties that can be defined in the SelphidConfiguration object will be commented on:
βΉοΈ All the configuration can be found in the component's fphi_sdkmobile_selphid/fphi_sdkmobile_selphid_configuration.dart file.
When making the call to the widget there is a series of parameters that must be included. They will be briefly discussed below.
3.1 resourcesPathβ
type: string
Sets the name of the resource file that the component will use for its graphical configuration. This file is customisable and is located in the plugin in the src/main/assets folder for Android and in the ios/Frameworks and Resources folder for iOS. Its installation is transparent to the user, it will simply be added to the respective platform's projects during plugin installation. More details about how this resource pack works and how to modify it are explained in section 6.
resourcesPath: "fphi-selphid-widget-resources-sdk.zip"
3.2 ShowResultAfterCaptureβ
type: boolean
Indicates whether or not to display a screen with the captured image of the document after the analysis process. This screen gives the user the option of repeating the capture process if the image obtained from the document is not correct.
showResultAfterCapture: false
3.3 ScanModeβ
type: WidgetScanMode
This enumeration is defined in the fphi_sdkmobile_selphid_scan_mode.dart class. Indicates the OCR scanning mode of the documents. Depending on the choice, several types of documents or one in particular will be scanned and searched. This mode can be of three types:
-
SelphIDScanMode.Generic: The generic mode that allows you to scan any type of document regardless of the country or the type of document. The result of this mode is not as accurate as the following, but it allows you to scan various standard documents.
-
SelphIDScanMode.Search: The search mode will allow you to use a whitelist and blacklist, and will search the documents that meet those conditions. These conditions are specified in the "specificData" variable. In this way it is possible to carry out the search limiting the number of templates, and making the search much more refined than in the generic case.
-
SelphIDScanMode.Specific: Search for a specific document. These conditions are indicated in the "specificData" property shown below.
scanMode: SelphIDScanMode.CAP_MODE_SEARCH;
3.4 SpecificDataβ
type: string
This property allows you to define which documents will be scanned during the process in the event of declaring the scan mode (scanMode) to GenericMode, SpecificMode or SearchMode.
An example of a configuration that allows all documents of Spanish nationality to be scanned would be the following:
scanMode: WidgetScanMode.Search;
specificData: βES|<ALL>β; // Spanish ISO code(ES)
3.5 documentSideβ
type: SelphIDDocumentSide
The permitted values are as follows:
-
SelphIDDocumentSide.FRONT: The widget is configured to capture the front side of the document.
-
SelphIDDocumentSide.BACK: The widget is configured to capture the back side of the document.
documentSide: SelphIDDocumentSide.FRONT;
3.6 FullScreenβ
type: boolean
Determines whether you wish the component to start in full screen mode, hiding the status bar.
fullscreen: true;
3.8 DocumentTypeβ
type: string
This enumeration is defined in the fphi_sdkmobile_selphid_document_type.dart class. Specified in the *SelphIDDocumentType class:
-
IDCard: Establishes that identity documents or cards will be captured.
-
Passport: Establishes that passports will be captured. (Additionally, the scanMode will have to be set to SelphIDScanMode.Generic).
-
DriverLicence: Establishes that driver's licences will be captured.
-
ForeignCard: It establishes that Foreigners' identity cards will be captured.
-
Custom: Includes documents that are not in any of the above categories.
documentType: SelphIDDocumentType.DT_IDCARD;;
3.9 TokenImageQualityβ
type: double
Specifies the compression quality of the tokenFaceImage.
Indicates whether the sdk returns to the application the images used during extraction or not. It should be noted that returning images can result in a significant increase in device resource usage:
tokenFaceImage: 0.9;
3.10 generateRawImagesβ
type: boolean
This property configures the component to return the full image from the camera that was used to capture the document:
- rawFrontDocument: Front image of the raw document.
- rawBackDocument: Rear image of the raw document.
- tokenRawFrontDocument: Tokenisation of the front image of the raw document.
- tokenRawBackDocument: Tokenisation of the rear image of the raw document.
generateRawImages: true
3.11 timeoutβ
type: SelphIDTimeout
It is an enumerator that defines the timeout of the capture of one side of the document. It has 3 possible values:
- SelphIDTimeout.Short: 15 seconds.
- SelphIDTimeout.Medium: 20 seconds.
- SelphIDTimeout.Long: 25 seconds.
- SelphIDTimeout.Long: 60 seconds.
timeout: SelphIDTimeout.Short;