Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Advanced settings

Introduction

This section provides additional general information about the SDK launch.


Advanced SDK Launch Information

This section provides additional information about the "Simplified SDK Launch" section.

Add a Private Repository

For security and maintenance reasons, new components of SDKMobile are stored in private repositories that require specific credentials to access. You must obtain these credentials from the support team at Facephi.

Once you have obtained the credentials, include the following code snippet to configure the Maven repository in Gradle for your project, or in its settings.gradle file. We recommend adding it after mavenCentral()

maven {
    Properties props = new Properties()
    def propsFile = new File('local.properties')
    if(propsFile.exists()){
        props.load(new FileInputStream(propsFile))
    }
    name="external"
    url = uri("https://facephicorp.jfrog.io/artifactory/maven-pro-fphi")
    credentials {
        username = props["artifactory.user"] ?: System.getenv("USERNAME_ARTIFACTORY")
        password = props["artifactory.token"] ?: System.getenv("TOKEN_ARTIFACTORY")
    }
}

To ensure that the project retrieves dependencies correctly, make sure the credentials (username and Token) are configured correctly.

There are several ways to configure the repository access credentials:

  • As environment variables with the following names. For example:

    If the dependencies are not recognized during synchronization, add them as environment variables in the file:

~/.zshrc

  • In the local.properties file, using the following structure:

SDK Initialization

Avoid initializing a controller that will not be used..

The SDK works through a main controller (SDKController), which must be initialized correctly to use the rest of its functionality. Follow these steps to initialize it:

  1. Include the Application object through the SdkApplication class.

  2. Decide whether to provide the license as a String or through a remote licensing service (see the License Injection).

  3. The TrackingController if you want to connect to the platform.

The third step is optional and requires using the Tracking component (see its documentation for more information about this module).

SdkConfigurationData has the following fields:

Field
Type
Required
Description

sdkApplication

SdkApplication

Yes

Application Application object for the application, wrapped in SdkApplication.

licensing

Licensing

Yes

License injection method: LicensingOnline or LicensingOffline (see License injection).

trackingController

ITrackingController?

No (default null)

Tracking controller (TrackingController) to connect to the platform.

locale

String?

No (default null)

SDK language (for example "es" or "en"). If it is null, empty, or invalid, the system language is used.

integrationId

String?

No (default null)

Integration identifier. Only applies to licenses that allow it (demo environments).

orientation

SdkViewOrientation

No (default FOLLOW_SYSTEM)

Orientation of the SDK views. Values: PORTRAIT, PORTRAIT_PHONES, LANDSCAPE and FOLLOW_SYSTEM.

internalOptions

SdkInternalOptions?

No (default null)

Internal options, for development or demo use only (see the Security).

An initialization example without TrackingController would be as follows:

An example of initialization with TrackingController would be as follows:

License injection

As mentioned previously, there are currently two ways to inject the license:

a. Obtaining the license through a service

Through a service that only requires an API key as an identifier and, optionally, a URL (url, whose default value is https://licensing.facephi.pro). This would avoid issues when handling the license, as well as the need to constantly replace licenses when a problem arises (corruption or improper modification, license expiration, etc.).

Kotlin implementation example:

b. Injecting the license as a String

The license can be assigned directly as a String, as follows:

Kotlin implementation example:

Error handling

For errors, we have the SdkError class.

List of errors:

All errors have the fields name, reason and code. Those that receive a parameter error: String expose it as the error.

  • EMPTY_LICENSE: Empty license (reason: SDK_EMPTY_LICENSE, code: SDK_003)

  • INIT_AI_MODELS(error: String): Error returned by the model download service (reason: SDK_INIT_AI_MODELS, code: SDK_100)

  • INIT_FLOW (error: String): Error returned by the flow download service (reason: SDK_INIT_FLOW, code: SDK_101)

  • LICENSE_CHECKER_ERROR (error: String): Error returned while checking whether the license is valid (reason: SDK_LICENSE_CHECKER_ERROR, code: SDK_102)

  • LICENSING_ERROR (error: String): Error returned by the license download service (reason: SDK_LICENSING_ERROR, code: SDK_103)

  • NETWORK_CONNECTION_ERROR: Internet connection error (reason: SDK_NETWORK_CONNECTION_ERROR, code: SDK_104)

  • OPERATION_ALREADY_LAUNCHED: An operation is already being created (reason: SDK_OPERATION_ALREADY_LAUNCHED, code: SDK_105)

  • TRACKING_ERROR (error: String): Error encountered when starting the tracking controller (reason: SDK_TRACKING_ERROR, code: SDK_106)

  • INTERNAL_ERROR (error: String): Internal error, mainly security-related; error contains a token for analysis (reason: SDK_INTERNAL_ERROR, code: SDK_135)

  • SDK_NOT_INITIALIZED_ERROR: The SDK has not been initialized correctly (reason: SDK_NOT_INITIALIZED_ERROR, code: SDK_136)


Start a new operation

Whenever you want to start the flow for a new operation (examples of operations include: onboarding, authentication, videoCall,...), it is essential to indicate to the SDKController that it is about to begin, so the SDK knows that the next calls to Components (also called Steps) will be part of that operation.

When starting a process or flow, you must always call the newOperation

method. This method has the following input parameters:

  1. operationType: Indicates whether the process will be ONBOARDING or AUTHENTICATION.

  2. customerId: (Optional) The user's unique ID, if available (managed at the application level).

    1. This parameter will be reflected for each operation on the platform.

  3. steps: (Optional) List of steps (Step) for the operation, if previously defined. Available values: SELPHI_COMPONENT, SELPHID_COMPONENT, NFC_COMPONENT, PHINGERS_COMPONENT, VIDEO_CALL_COMPONENT, VIDEO_ID_COMPONENT, VIDEO_RECORDING_COMPONENT, VOICE_COMPONENT, QR_CAPTURE_COMPONENT and PHACTURA_CAPTURE_COMPONENT.

  4. enableTracking: Enables or disables sending tracking events for this operation. If not specified, it is considered true.

There are two ways to start an operation, depending on whether the steps are known that will make up the registration or authentication process flow (if the components are executed sequentially and always in the same way) or, otherwise, whether the flow is undefined and unknown (for example, when the end customer decides the order in which the components are executed).

  • Flow known (the operation will appear tracked on the platform with all the steps in the list).

    Kotlin implementation example:

  • Flow unknown (the operation will appear tracked on the platform with ellipses). Kotlin implementation example:

result → Contains in data the information for the created operation.

When the result is successful, data is an OperationResult with:

Field
Description

sessionId

Identifier of the session created or retrieved by the SDK.

operationId

Identifier of the active operation.

type

Type of operation started (ONBOARDING or AUTHENTICATION).

customerId

User identifier associated with the operation.

Once the operation has been created you can run the SDK components associated with this operation. See the documentation for each component to learn how.

Existing operation types

Currently, the following operations are available, each of which uses specific components (STEPS).

The following table shows the relationship between operations and steps:

Operation (OperationType)

Component (Step)

Description

ONBOARDING

SELPHI_COMPONENT SELPHID_COMPONENT

- Facial verification of a selfie against the face in a document - Document OCR extraction - Liveness detection

AUTHENTICATION

SELPHI_COMPONENT

- Facial verification using templates - Liveness detection

This list will be expanded in future SDK updates as new components and use cases become available.

If creating a new operation returns an error of type INTERNAL_ERROR this is mainly due to a security. To investigate the cause, you can retrieve the token associated with the error, which provides additional information for analysis.


Security

The Android SDK includes a security system designed to detect and block potentially untrusted environments or those that may indicate attack attempts.

This mechanism is enabled by default. It identifies situations that could compromise security and prevents the SDK from running in contexts that are not considered safe. When an unsafe environment is detected, creating the operation (newOperation) returns an SdkError.INTERNAL_ERROR with a token for analysis (see the Start a new operation).

section). The method SDKController.securityMode(...) is no longer available. Check control is handled through the internalOptions parameter of SdkConfigurationData (or via SDKController.setInternalParams), and is reserved for development or demo environments only, not production:

Available keys in SdkInternalOptions.params:

Key
Value
Effect

SKIP_ENV_CHECK

"true"

Disables secure environment evaluation (for example, to allow testing in emulators). Any other value keeps the evaluation active.

SECURITY_PROFILE

"STRICT", "BALANCED" or "PERMISSIVE"

Environment evaluation blocking profile. By default, PERMISSIVE; an invalid value keeps PERMISSIVE.


Launching components

The SDK's functionality is divided into different components with dedicated controllers. These controllers are launched from the main controller.

Once the new operation (section 3) has been created, the different SDK controllers can be launched. For more information, refer to the documentation for each specific component.

Kotlin launch example:

Options for launching the component

Once the SDK has been initialized and a new operation has been created, the component can be launched. There are two ways to launch the component:

  • [WITH TRACKING] This call launches the component's functionality as usual, while tracking internal events to the tracking:

  • [WITHOUT TRACKING] This call launches the component's functionality as usual, but no events will be tracked to the tracking:

The method launch should be used by default. This method allows you to use tracking when its component is enabled, and will not use it when the component is disabled (or is not installed).

On the other hand, the launchMethod method covers a special case in which the integrator has tracking installed and enabled, but does not want to track information in a particular flow within the application. In this case, this method is used to prevent that information from being sent to the platform.


Returning a result

The result of each component is returned through the SDK, always maintaining the same structure via the SdkResult class, which is a sealed class that can have two possible states:

  • SdkResult.Success: Indicates that the operation completed successfully and contains:

    • data: Contains the data type required by the launched process/component.

  • SdkResult.Error

    • error: Contains the error type required by the launched process/component.

The documentation for each specific component details the different fields this object can return.

Usage example:


Auxiliary controllers

This section includes other auxiliary controllers and operations, some of which are optional and may be required for the flow to complete successfully.

These fields are required to communicate with the Facephiservice if you want to perform any verification and want to perform tracking for a specific operation.

Retrieving the Operation ID

Retrieving the OperationType

Retrieving the Session ID

Retrieving the Customer ID

Assigning the Customer ID

Canceling the running component

Sends a cancellation notification to the SDK to stop the component that is currently running.

Closing the session

Closes the current SDK session: closes the tracking session (if active), deletes the session and operation data, clears the saved customization, and releases internal services. After calling it, you will need to initialize the SDK again (initSdk) and create a new operation to launch components.

Restoring an existing session

Allows you to retrieve the identifiers of a previously created session and operation (all parameters are required):

If the secure environment control blocks restoration, an SdkError.INTERNAL_ERROR.


Debugging and error handling options

The SDK includes certain options that increase debugging logs, allowing you to verify that everything is working correctly.

Error handling for Tracking connections to the platform

Once the SDK has started successfully, you can apply certain settings to get more information about potential tracking errors. You can monitor them using this controller launch:

Enabling general debug logs

Receiving SDK logs in the application

You can receive all log messages emitted by the SDK in the application using SDKController.setLoggerBackend, specifying a CallbackLoggerBackend. The callback receives the level (CallbackLoggerLevel: VERBOSE, DEBUG, INFO, WARN or ERROR), the tag, the message, and optionally, the associated exception:

To stop receiving logs, you can call the method with null:


Tracking and analyzing events in the application

The events feature lets you record and interpret key interactions within the application, such as screen changes and user actions, making it easier to analyze behavior in real time.

Each event is sent with a timestamp, type, and specific details, providing structured tracking and optimizing the user experience with precise, actionable data.

The callback receives the following parameters:

  • time (Long): event timestamp.

  • componentName (ComponentName): component that generates the event. Values: NFC_COMPONENT, VOICE_COMPONENT, DISCLAIMER_COMPONENT, DOCUMENT_CAPTURE_COMPONENT, QR_CAPTURE_COMPONENT, SELPHID_COMPONENT, SELPHI_COMPONENT, SELPHI_SIGNATURE_COMPONENT, VIDEO_ID_SIGNATURE_COMPONENT, PHINGERS_COMPONENT, PHINGERS_TF_COMPONENT, VIDEO_ID_COMPONENT, VIDEO_CALL_COMPONENT and VIDEO_RECORDING_COMPONENT.

  • eventType (EventType): event type. Values: SCREEN_VIEW, BUTTON_CLICK, COMPONENT_STARTED and COMPONENT_STOPPED.

  • info (String?): event-specific detail, if any.

Last updated