Usage

Register Activity Request for Result

Before initializing the SDK, an activity must be defined to receive the result. For this purpose, use the registerForActivityResult method with the AmparoIdResultContract contract which will be used to launch the SDK. The following code snippet shows how to register

private val amparoLauncher = registerForActivityResult(AmparoIdResultContract()) { result ->
    when (result) {
        AmparoIdSdkResponse.SUCCESS -> onSuccess()
        AmparoIdSdkResponse.CANCELLED  -> onCancelled()
        else -> onFailure()
    }
}

Where onSuccess(), onCancelled(), and onFailure() are methods defined by you to be executed when the SDK returns a success, cancellation, or failure response, respectively.

The AmparoIdSdkResponse enum contains the possible responses from the SDK:

  • SUCCESS: the SDK returned a successful response.
  • CANCELLED: the SDK was cancelled.
  • FAILURE: the SDK returned a failure response.

When SUCCESS is returned, the identification result must be checked by your backend.

Creating SDK Configuration

The following parameters are required for SDK configuration:

  • API_KEY: key for API endpoint consumption.
  • API_URL: API base url.
  • E_CERT: security certificate used by the SDK.
  • KSM_KEY: SDK security key.
  • SKM_KEY: SDK security key.
  • CONTACT_SUPPORT: your callback to contact support.
  • DEFAULT_COUNTRY: the default country for the SDK, which is CHL (Chile) by default. Support for other countries is available, such as URY (Uruguay).

To use the Amparo ID SDK, create a configuration using the AmparoIdSdkConfig object as shown below:

val amparoIdSdkConfig = AmparoIdSdkConfig.Builder()
    .setApiKey("API_KEY")
    .setBaseUrl("API_URL")
    .setECert("E_CERT")
    .setKsmKey("KSM_KEY")
    .setSkmKey("SKM_KEY")
    .setContactSupport { /* your callback to contact support */ }
    .setDefaultCountry("URY")
    .build()

This instance will be used when invoking the SDK.

Initializing the SDK

Obtain an instance of AmparoIdApi:

amparoIdSdk = AmparoIdApiFactory.create()

Call the SDK using the defined launcher:

amparoIdSdk!!.startActivityForResult(this@MainActivity, amparoIdSdkConfig, amparoLauncher)

SDK Customization

Defining colors

To customize the SDK colors, define colors in the themes.xml file:

<style name="AppTheme" parent="AmparoIdSdkTheme">
    <item name="amparoIdPrimaryMain">@color/purple_200</item>
    <item name="amparoIdPrimaryLight">@color/purple_500</item>
</style>

With AppTheme as the application theme, the SDK will use the defined colors for amparoIdPrimaryMain and amparoIdPrimaryLight.

Defining texts

To customize the SDK texts, define strings in the strings.xml file:

NameString
amparo_id_sdk_success_message_1¡Listo!
amparo_id_sdk_success_message_2Lo hiciste muy bien.
amparo_id_sdk_error_no_verificationsNo tienes verificaciones pendientes
amparo_id_sdk_error_disconnectNo es posible continuar con la verificación
amparo_id_sdk_error_verification_failedNo pudimos verificar tu identidad
amparo_id_sdk_error_incompatibleLo sentimos, esta app no está disponible para este dispositivo.
amparo_id_sdk_error_timer¿Necesitas ayuda con este paso?
amparo_id_sdk_error_deprecated¡Tenemos lista una nueva actualización!
amparo_id_sdk_error_nfc_disabledActiva el lector de NFC de tu dispositivo móvil
amparo_id_sdk_error_nfc_interrupted¡Se interrumpió el proceso!
amparo_id_sdk_error_no_verifications_descriptionNo encontramos verificaciones asociadas a tu RUT. Si crees que esto es un error, por favor contáctanos.
amparo_id_sdk_error_disconnect_descriptionEn este momento nuestros servicios no están disponibles, estamos trabajando en resolverlo. Inténtalo más tarde.
amparo_id_sdk_error_without_retry_descriptionPor favor contacta a un ejecutivo.
amparo_id_sdk_error_with_retry_descriptionPor favor inténtalo de nuevo o contáctanos.
amparo_id_sdk_error_incompatible_descriptionContáctanos para que podamos ayudarte.
amparo_id_sdk_error_deprecated_descriptionPara que tu App sea aún más segura y la puedas usar, necesitamos que esté actualizada.
amparo_id_sdk_error_disabled_descriptionEn conexiones del dispositivo, encuentra NFC y habilítalo.
amparo_id_sdk_error_interrupted_descriptionSi luego de varios intentos el problema persiste, contacta a un ejecutivo.
amparo_id_sdk_error_retry_main_buttonVolver a intentar
amparo_id_sdk_error_got_it_main_buttonEntendido
amparo_id_sdk_error_incompatible_main_buttonContactar a Servicio al Cliente
amparo_id_sdk_error_timer_main_buttonContactar a Servicio al Cliente
amparo_id_sdk_error_deprecated_main_buttonActualizar App
amparo_id_sdk_error_nfc_disabled_main_buttonAbrir conexiones
amparo_id_sdk_error_nfc_interrupted_main_buttonVolver a escanear
amparo_id_sdk_error_contact_support_secondary_buttonContactar a Servicio al Cliente
amparo_id_sdk_error_later_secondary_buttonEn otro momento
amparo_id_sdk_error_dismiss_secondary_buttonNo, gracias
amparo_id_sdk_error_nfc_bad_reading_1La cédula de identidad fue retirada durante el escaneo.
amparo_id_sdk_error_nfc_bad_reading_2La carcasa de tu móvil bloquea el escaneo. Retírala y vuelve a intentarlo.
amparo_id_sdk_error_nfc_bad_reading_error_descriptionPor favor, revisa las posibles causas y cuando estés listo, vuelve a intentarlo.