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 isCHL(Chile) by default. Support for other countries is available, such asURY(Uruguay).NFC_MAX_TRIES: maximum number of NFC reading attempts, which is3by default.
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")
.setNfcMaxTries(3)
.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:
| Name | String |
|---|---|
amparo_id_sdk_success_message_1 | ¡Listo! |
amparo_id_sdk_success_message_2 | Lo hiciste muy bien. |
amparo_id_sdk_error_no_verifications | No tienes verificaciones pendientes |
amparo_id_sdk_error_disconnect | No es posible continuar con la verificación |
amparo_id_sdk_error_verification_failed | No pudimos verificar tu identidad |
amparo_id_sdk_error_incompatible | Lo 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_disabled | Activa el lector de NFC de tu dispositivo móvil |
amparo_id_sdk_error_nfc_interrupted | ¡Se interrumpió el proceso! |
amparo_id_sdk_error_id_incompatible | No es posible validar esta cédula |
amparo_id_sdk_error_no_verifications_description | No encontramos verificaciones asociadas a tu RUT. Si crees que esto es un error, por favor contáctanos. |
amparo_id_sdk_error_disconnect_description | En este momento nuestros servicios no están disponibles, estamos trabajando en resolverlo. Inténtalo más tarde. |
amparo_id_sdk_error_without_retry_description | Por favor contacta a un ejecutivo. |
amparo_id_sdk_error_with_retry_description | Por favor inténtalo de nuevo o contáctanos. |
amparo_id_sdk_error_id_incompatible_description | Las cédulas con formato anterior no son compatibles con el proceso de verificación, por favor, comunícate al 1787 para que podamos asesorarte. |
amparo_id_sdk_error_incompatible_description | Contáctanos para que podamos ayudarte. |
amparo_id_sdk_error_deprecated_description | Para que tu App sea aún más segura y la puedas usar, necesitamos que esté actualizada. |
amparo_id_sdk_error_disabled_description | En conexiones del dispositivo, encuentra NFC y habilítalo. |
amparo_id_sdk_error_interrupted_description | Si luego de varios intentos el problema persiste, contacta a un ejecutivo. |
amparo_id_sdk_error_retry_main_button | Volver a intentar |
amparo_id_sdk_error_got_it_main_button | Entendido |
amparo_id_sdk_contact_support_button | Contactar a Servicio al Cliente |
amparo_id_sdk_error_deprecated_main_button | Actualizar App |
amparo_id_sdk_error_nfc_disabled_main_button | Abrir conexiones |
amparo_id_sdk_error_nfc_interrupted_main_button | Volver a escanear |
amparo_id_sdk_error_later_secondary_button | En otro momento |
amparo_id_sdk_error_dismiss_secondary_button | No, gracias |
amparo_id_sdk_error_nfc_bad_reading_1 | La cédula de identidad fue retirada durante el escaneo. |
amparo_id_sdk_error_nfc_bad_reading_2 | La carcasa de tu móvil bloquea el escaneo. Retírala y vuelve a intentarlo. |
amparo_id_sdk_error_nfc_bad_reading_error_description | Por favor, revisa las posibles causas y cuando estés listo, vuelve a intentarlo. |