Selphi Component
1. Introductionβ
The Component addressed in the current document is called the Selphi Component. This is responsible for capturing a selfie of the user and the subsequent extraction of the most important facial characteristics. Its main functionalities are the following:
- Internal camera management.
- Permissions management.
- Assists the processes of capturing the user's face.
- Generation of templates with the facial characteristics and the image of the user's face for the Liveness detection process
1.1 Minimum requirementsβ
- If the Injection Attack Detection (IAD) feature is used, then: API level 24 RAM: 3 GB
1.2 Plugin versionβ
The current plugin version can be checked as follows:
- Look for the package.json 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_SELPHI_FACE_PATH%> - Path to the root of the current plugin (example /folder/sdk-selphi)
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 react-native is installed.
-
Access APPLICATION_PATH at a terminal and run:
yarn add @facephi/sdk-core-react-native
yarn add @facephi/sdk-selphi-react-native
yarn add @facephi/sdk-selphi-iad-react-native(Only if you use Selphi IAD)
- In addition, to install the plugin on iOS, the following must also be executed:
cd ios
pod install
- It is important to verify that the path to the plugin is correctly defined in package.json:
"dependencies": {
"@facephi/sdk-core-react-native": <% PLUGIN_CORE_PATH %>,
"@facephi/sdk-selphi-react-native": <% PLUGIN_SELPHI_FACE_PATH %>
}
After running the above steps, you can start the app with the sdk/component installed.
- Finally, to launch the projects, the following commands must be executed in two ways:
From Terminal (For Android):
npx react-native run-android
or
npx react-native run-android --active-arch-only
From Terminal (For iOS):
npx react-native run-ios
From different IDEs
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 component, 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 Update the Podfileβ
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 environment 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.1 Set Android SDK versionβ
For Android, the minimum SDK version required by our native libraries is 23, 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 actual component contains a number of Typescript methods and interfaces contained within the node_modules/@facephi/sdk-selphi-react-native/src/index.ts 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.
Below is the SelphiConfiguration class, which allows you to configure the Selphi component:
export interface SelphiConfiguration
{
fullscreen?: boolean;
cropPercent?: number;
crop?: boolean;
stabilizationMode?: boolean;
templateRawOptimized?: boolean;
resourcesPath?: string;
enableGenerateTemplateRaw?: boolean;
livenessMode?: SdkLivenessMode;
showResultAfterCapture?: boolean;
translationsContent?: string;
viewsContent?: string;
showTutorial?: boolean;
videoFilename?: string;
showDiagnostic?: boolean;
logImages?: boolean;
}
βΉοΈ All the configuration can be found in the component's node_modules/@facephi/sdk-selphi-react-native/src/src/index.tsx file.
When making the call to the component 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-selphi-widget-resources-sdk.zip",
3.2. cropβ
type: boolean
Indicates whether the images returned (in the images parameter that is activated with enableImages = true) in the completion event contain only the area of ββthe detected face, at a magnification given by CropPercent, or whether the entire image is returned.
crop: false
3.3. cropPercentβ
type: float
Specifies the magnification percentage of the detected face area to compose the returned image.
cropPercent: 1.0
3.5. livenessModeβ
type: SdkLivenessMode
Sets the liveness mode of the component. The possible values are:
-
NoneMode: Indicates that the photodetection mode should not be enabled in authentication processes.
-
PassiveMode: Indicates that the passive life test is carried out on the server, sending the corresponding "BestImage" for this purpose
-
MoveMode: Indicates that the liveness test is active by displaying instructions during the capture, and returning the corresponding result of the process.
livenessMode: SdkSelphiEnums.SdkLivenessMode.PassiveMode
3.6. stabilizationModeβ
type: boolean
Property that allows activating or deactivating the stabilised mode before the face detection process. In the case of being activated, it will give some guidelines to know if it is correctly located or not.
stabilizationMode: true
3.8. fullScreenβ
type: string
Sets whether you want the sdk to start in full screen mode, hiding the status bar.
fullscreen: true
3.9. logImagesβ
type: string
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:
logImages: false
3.10. templateRawOptimizedβ
type: boolean
Indicates whether if the selfie token generated must be optimized or not.
templateRawOptimized: false
3.11. showDiagnosticβ
type: boolean
Shows a pop-up with the component diagnostic if the process fails.
showDiagnostic: true