Core


Currently, we have new version of the SDK available. (Click to see more information)

4.3.2 🚀 Latest

The Core library allows you to start the flow of the user and allows you to communicate between the modules and the server.

Quick start


Add core as a dependency in your build.gradle app.

build.gradle:app
implementation 'com.autentikar:core:4.3.2'

Set up


Initialize SDK

Before continuing, you can set up the SDK with the following code, we recommend that you do this in the Application class:

Kotlin
import com.autentikar.core.init.AKCore

fun initSDK() {
  AKCore.start(this, "YOUR_SIGNATURE_KEY")
  AKCore.backendAuth("YOUR_USER_KEY", "YOUR_PASSWORD_KEY") // it's deprecated starting from version 4.3.0, instead use the method basicAuth
  AKCore.basicAuth("YOUR_USER_KEY", "YOUR_PASSWORD_KEY") // available from version 4.3.0
}
Java
import com.autentikar.core.init.AKCore;

public void initSDK() {
  AKCore.start(this, "YOUR_SIGNATURE_KEY");
  AKCore.backendAuth("YOUR_USER_KEY", "YOUR_PASSWORD_KEY"); // it's deprecated starting from version 4.3.0, instead use the method basicAuth
  AKCore.basicAuth("YOUR_USER_KEY", "YOUR_PASSWORD_KEY"); // available from version 4.3.0
}

Basic configuration


To configure the flow start into your specific activity you have to call the init method of the AKCore class with multiple init flow options.

For new accouts created after 2023-04-01, the Options.account parameter is mandatory.

The following example shows how to start the flow with different options:

inFlowID

Kotlin
import com.autentikar.core.init.options.Options
import com.autentikar.core.init.AKCore
import com.autentikar.core.init.options.ResponseType
import com.autentikar.core.data.types.CoreStage
import com.autentikar.core.data.model.User

Options.account = "your_account"
val options = Options.start.inFlowID(
      "YOUR_FLOW_ID", User(
      "CL",
      "CI",
      "000"),
      CoreStage.DEV||QA||PROD,
      responseType = ResponseType.INSTANCE_RESPONSE)

AKCore.init(launcher, options)
Java
import com.autentikar.core.init.options.Options;
import com.autentikar.core.init.AKCore;
import com.autentikar.core.init.options.ResponseType;
import com.autentikar.core.data.types.CoreStage;
import com.autentikar.core.data.model.User;
import com.autentikar.core.data.model.InitFlow;


Options.setAccount("your_account");
User user = new User("CL","CI","000");
InitFlow options = Options.getStart().inFlowID("YOUR_FLOW_ID", user, CoreStage.DEV||QA||PROD, null, ResponseType.INSTANCE_RESPONSE);
AKCore.init(laucher, options);

inExternalApp

Kotlin
import com.autentikar.core.init.options.Options
import com.autentikar.core.init.AKCore
import com.autentikar.core.data.types.CoreStage

Options.account = "your_account"
val options = Options.start.inExternalApp(
  "nextToken",
  "authToken",
  CoreStage.DEV||QA||PROD
)

AKCore.init(launcher, options)
Java
import com.autentikar.core.init.options.Options;
import com.autentikar.core.init.AKCore;
import com.autentikar.core.data.types.CoreStage;
import com.autentikar.core.data.model.InitFlow;


Options.setAccount("your_account");
User user = new User("CL","CI","000");
InitFlow options = Options.getStart().inExternalApp("nextToken", "authToken", CoreStage.DEV||QA||PROD);
AKCore.init(laucher, options);
Options

The Options class is a class that allows you to configure the flow init, it has the following basic option:

account

The account property is a property that allows you to configure the account that you want vinculate to the flow. Is mandatory for new accounts created after 2023-04-01.

start

The start property is a class that allows you to configure the flow start, it has the following options:

inFlowID

The inFlowID method is a method that allows you to configure the flow start with the following parameters:

  • flowID: The flow id that you want to start.
  • user: The user class that will start the flow.
  • stage: The stage of the flow that you want to start, for default is PROD.
  • customFields: The custom fields that you want to send to the flow.
  • files: The files that you want to send to the flow, it's map<string,string> type, you can add files in base64.
  • responseType: The type of response that the SDK will return to the application, for default is INSTANCE_RESPONSE.
inExternalApp

The inExternalApp method is a method that allows you to resume a previous flow the next step with the following parameters:

  • nextToken: The next token is an identifier that allows you to start a flow from an external application.
  • authToken: The auth token is an identifier that allows you validate the app that is starting the flow.
  • stage: The stage of the flow that you want to start, for default is PROD.
inNextStep

The inNextStep method is a method that allows you to resume a previous flow the next step with the following parameters:

  • nextStepToken: The next step token is an identifier that allows you to resume a previous flow.
  • stage: The stage of the flow that you want to start, for default is PROD.

The inExternalLink method is a method that allows you to start a flow from an external link with the following parameters:

  • token: The token is an identifier that allows you to start a flow from an external link.

User


The User class is a class that allows you to configure the user that will start the flow, it has the following options:

  • country: The country of the user.
  • docType: The document type of the user.
  • idNum: The document number of the user.

ResponseType


The ResponseType class is an enum that allows you to configure the type of response that the SDK will return to the application, it has the following options:

  • RESULT: Returns the result of the last step.
  • INSTANCE_ID: Returns the instance id of the current flow.
  • INSTANCE_RESPONSE: Returns the final result of the flow.
  • FULL: Return all the information of the flow.

Advanced configuration


If you need to configure the flow start with more options as timeout petitions you can use this method:

Kotlin
  import com.autentikar.core.init.options.Options

  Options.instanceStatusTimeout = 60000L // Timeout in milliseconds Long
Java
import com.autentikar.core.init.AKCore;

Options.setInstanceStatusTimeout(60000L); // Timeout in milliseconds Long

ActivityResultLauncher


The ActivityResultLauncher is a class that allows you to start an activity for a result and receive the result in a callback, without the need to implement the onActivityResult method.

The following example shows how to use the ActivityResultLauncher class with different options:

inFlowID

Kotlin
import com.autentikar.core.data.types.AKResultType
import com.autentikar.core.init.contracts.AKFlowResultContract
import com.autentikar.core.data.model.AKReturn

private var launcher = registerForActivityResult(AKFlowResultContract()) {
      when (it.first) {
          AKResultType.RESULT -> {
              val akReturn =  it.second ?: AKReturn()
          }
          else -> {
              // User canceled the flow
          }
      }
  }
Java
import com.autentikar.core.data.types.AKResultType;
import com.autentikar.core.init.contracts.AKFlowResultContract;
import com.autentikar.core.data.model.AKReturn;

private final ActivityResultLauncher<Unit> flowResultLauncher = registerForActivityResult(new AKFlowResultContract(), result -> {
      if (result.component1() == AKResultType.RESULT) {
          Intent intent = new Intent();
          AKReturn akResult = result.component2();
      } else {
          // User canceled the flow
      }
  });

inExternalApp

Kotlin
import com.autentikar.core.data.types.AKResultType
import com.autentikar.core.init.contracts.AKExternalAppResultContract

private var launcher = registerForActivityResult(AKExternalAppResultContract()) {
      when (it.first) {
          AKResultType.RESULT -> {
            // Success (not is mandatory get the result)
          }
          else -> {
              // User canceled the flow
          }
      }
  }
Java
import com.autentikar.core.data.types.AKResultType;
import com.autentikar.core.init.contracts.AKExternalAppResultContract;

private final ActivityResultLauncher<Unit> flowResultLauncher = registerForActivityResult(new AKExternalAppResultContract(), result -> {
      if (result.component1() == AKResultType.RESULT) {
          // Success (not is mandatory get the result)
      } else {
          // User canceled the flow
      }
  });

AKResultType


The AKResultType class is an enum that allows you to configure the type of result that the SDK will return to the application, it has the following options:

  • RESULT: Is success, obtain AKReturn class.
  • CANCEL_BY_USER: Is cancel by user, null or empty AKReturn class.
  • WITHOUT_RESULT: Is cancel by an error or app, null or empty AKReturn class.

AKReturn


The AKReturn class is the response that the SDK returns to the application, it contains the following information:

  • result: The result of the last step, it's of type Any but it is Dynamic Json.
  • instanceId: The instance id of the current flow.
  • instanceResponse: The final result of the flow, it's of type Any but it is LinkedTreeMap Json.

Proguard


If you are using proguard you have to add the following lines to your proguard file:

proguard-rules.pro
 -keep class com.autentikar.** { *; }

Custom Theme


If you want to use a custom theme you have to add the AKCoreCustomization class:

Kotlin
import com.autentikar.core.ui.customization.AKCoreCustomization

val coreCustomization = AKCoreCustomization()
val button = AKCoreCustomization.Button()

// Loading Screen
coreCustomization.backgroundColor = Color.parse("#your_background_color")
coreCustomization.showBackgroundImage = true | false
coreCustomization.backgroundImage = R.drawable.your_background_image
coreCustomization.showLogo = true | false
coreCustomization.logo = R.drawable.your_logo
coreCustomization.progressBarColor = Color.parse("#your_progress_bar_color")
coreCustomization.textColor = Color.parse("#your_text_color")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  customization.customFontTypeface = resources.getFont(R.font.your_custom_font)
} else {
  coreCustomization.customFontTypeface = your_custom_font_typeface // example: ResourcesCompat.getFont(this, R.font.yout_font)
}

// Button
button.backgroundColor = Color.parse("#your_background_color")
button.textColor = Color.parse("#your_text_color")
button.disableTextColor = Color.parse("#your_disable_text_color")
button.disableBackgroundColor = Color.parse("#your_disable_background_color")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  button.customFontTypeface = resources.getFont(R.font.your_custom_font)
} else {
  button.customFontTypeface = your_custom_font_typeface // example: ResourcesCompat.getFont(this, R.font.yout_font)
}
button.textSize = 25f


coreCustomization.buttonCustomization = button
      
AKCore.setCustomization(coreCustomization)
Java
import com.autentikar.core.ui.customization.AKCoreCustomization;

AKCoreCustomization customPrincipal = new AKCoreCustomization();
AKCoreCustomization.Button button = new AKCoreCustomization.Button();

// Loading Screen
customPrincipal.setBackgroundColor(your_background_color);
customPrincipal.setShowBackgroundImage(true | false);
customPrincipal.setBackgroundImage(R.drawable.your_background_image);
customPrincipal.setShowLogo(true | false);
customPrincipal.setLogo(R.drawable.your_logo);
customPrincipal.setProgressBarColor(your_progress_bar_color);
customPrincipal.setTextColor(your_text_color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  customPrincipal.setCustomFontTypeface(getResources().getFont(R.font.your_custom_font));
} else {
  customization.setCustomFontTypeface(Typeface.createFromAsset(getAssets(), "fonts/your_custom_font.ttf")); // example: Typeface.createFromAsset(assets, "fonts/your_custom_font.ttf")
}

// Button
button.setBackgroundColor(your_background_color);
button.setTextColor(your_text_color);
button.setDisableBackgroundColor(your_disable_background_color);
button.setDisableTextColor(your_disable_text_color);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  button.setCustomFontTypeface(getResources().getFont(R.font.your_custom_font));
} else {
  button.setCustomFontTypeface(Typeface.createFromAsset(getAssets(), "fonts/your_custom_font.ttf")); // example: Typeface.createFromAsset(assets, "fonts/your_custom_font.ttf")
}
 button.setTextSize(25f);

cardCustomization.setButtonCustomization(button);

AKCore.setCustomization(customPrincipal);

Properties


This class has the following properties:

Loading Screen


  • backgroundColor: The background color of principal screen.
  • showBackgroundImage: Show or hide the background image in principal screen (default is false).
  • backgroundImage: The background image of principal screen (if showBackgroundImage is false this image not show).
  • showLogo: Show or hide the logo in principal screen (default is true).
  • logo: The logo bottom of principal screen (if showLogo is false this image not show).
  • progressBarColor: The color of progress bar in principal screen.
  • textColor: The color of text in principal screen.
  • customFontTypeface: The custom font of text in principal screen. Deprecated
  • titleFontTypeface: The custom font of title in principal screen. New
  • textFontTypeface: The custom font of text in principal screen. New
  • fileViewerCustomization: The custom style of file viewer. New
  • otpCustomization: The custom style of otp. New

Button


  • backgroundColor: The background color. Deprecated
  • primaryBackgroundColor: The primary background color. New
  • secondaryBackgroundColor: The secondary background color. New
  • textColor: The color of text. Deprecated
  • primaryTextColor: The primary color of text. New
  • secondaryTextColor: The secondary color of text. New
  • disableTextColor: The color of text when the button is disabled.
  • disableBackgroundColor: The background color when the button is disabled.
  • customFontTypeface: The custom font typeface button. Deprecated
  • fontTypeface: The font typeface button. New
  • textSize: The size of text.

FileViewer


This properties are available from version 4.3.0.

  • checkBoxColorWhenChecked: The color of the checkbox when is checked.
  • checkBoxColorWhenNotchecked: The color of the checkbox when is unchecked.
  • image: The image of the file viewer.

OTP


This properties are available from version 4.3.0.

  • layoutBorder: The border of the otp layout.
  • layoutBorderTextField: The border of the otp text field.
  • backgroundColor: The background color of the otp.
  • textColor: The color of the otp text.
  • showFinishVerificationButton: Show or hide the finish verification button.

Custom alert style

If you want to customize the alert style you can add the following style in your styles.xml file:

styles.xml
<style name="AlertDialogCustom" parent="Base.Theme.AppCompat.Dialog.Alert">
  <item name="android:windowBackground">#FFFFFF</item>
  <item name="android:textColorPrimary">#000000</item>
  <item name="android:textColorSecondary">#000000</item>
  <item name="colorAccent">#FE5000</item>
</style>

And set the style in the AKCoreCustomization class with alertStyle property.

Texts


For change the texts of loading screen, you can override the following strings in your strings.xml file:

If you want to change the texts, you have to add strings.xml (es) file in your project for spanish language.
strings.xml
<!--Core Activity-->
<string name="ak_core_ui_starting_auth">Starting Auth Client &amp; SDK</string>
<string name="ak_core_ui_processing_auth">Processing Auth Client &amp; SDK</string>
<string name="ak_core_ui_processing_data">Processing %1$s</string>
<string name="ak_core_ui_ending_flow">Ending Verification</string>
<string name="ak_core_ui_cancel_operation">Canceling Operation</string>
<string name="ak_core_dynamic_flow_event_max_retries">The maximum number of retries has been exceeded.\nTry again later.</string>
<string name="ak_core_ui_next_step">Next Step</string>
<string name="ak_core_ui_information">Information</string>
<string name="ak_core_ui_result">Result</string>

<!--File Viewer Activity-->
<string name="ak_core_accept_documents">To continue you must accept\nthe documents. (%1$d)</string>
<string name="ak_core_loading_documents">Loading documents</string>
<string name="ak_core_having_trouble_document">Having trouble viewing the document? Please close the viewer and reopen it.</string>

<!--OTP Activity-->
<string name="ak_core_otp_title">SMS Capture</string>
<string name="ak_core_otp_message">To ensure the security of your transaction, we have sent a verification code to your registered mobile number.</string>
<string name="ak_core_otp_sendCodeOTP">Verify OTP code</string>
<string name="ak_core_otp_resendCodeOTP">Resend OTP code</string>
<string name="ak_core_otp_verifier_otp_code">Verifying OTP code</string>
<string name="ak_core_otp_resend_otp_code">Resending OTP code</string>
<string name="ak_core_otp_footer_message">If you have not received the OTP code, you can request a new code that will be sent to your cell phone.</string>
<string name="ak_core_otp_sent_successfully">OTP code sent</string>
<string name="ak_core_otp_sent_not_successfully">The OTP code was not sent, try again</string>
<string name="ak_core_otp_not_valid_or_expired">The OTP code is invalid or has expired.\nPlease try again.</string>
<string name="ak_core_otp_not_valid">The OTP code is invalid.</string>
strings.xml (es)
<!--Core Activity-->
<string name="ak_core_ui_starting_auth">Iniciando Auth Client &amp; SDK</string>
<string name="ak_core_ui_processing_auth">Procesando Auth Client &amp; SDK</string>
<string name="ak_core_ui_processing_data">Procesando %1$s</string>
<string name="ak_core_ui_ending_flow">Finalizando Verificación</string>
<string name="ak_core_ui_cancel_operation">Cancelando Operación</string>
<string name="ak_core_dynamic_flow_event_max_retries">Se superado el número máximo de intentos.\Inténtelo de nuevo más tarde.</string>
<string name="ak_core_ui_next_step">Siguiente Paso</string>
<string name="ak_core_ui_information">Información</string>
<string name="ak_core_ui_result">Resultado</string>

<!--File Viewer Activity-->
<string name="ak_core_accept_documents">Para continuar es necesario que aceptes\nlos documentos. (%1$d)</string>
<string name="ak_core_loading_documents">Cargando documentos</string>
<string name="ak_core_having_trouble_document">¿Tienes problemas para ver el documento? Por favor, cierra el visor y ábrelo de nuevo.</string>

<!--OTP Activity-->
<string name="ak_core_otp_title">Captura de SMS</string>
<string name="ak_core_otp_message">Para garantizar la seguridad de tu transacción, hemos enviado un código de verificación a tu número de celular registrado.</string>
<string name="ak_core_otp_sendCodeOTP">Verificar código otp</string>
<string name="ak_core_otp_resendCodeOTP">Reenviar código otp</string>
<string name="ak_core_otp_verifier_otp_code">Verificando código OTP</string>
<string name="ak_core_otp_resend_otp_code">Reenviando código OTP</string>
<string name="ak_core_otp_footer_message">Si no has recibido el código OTP, puedes solicitar un nuevo código que será enviado a tu celular.</string>
<string name="ak_core_otp_sent_successfully">Se enviado el código OTP</string>
<string name="ak_core_otp_sent_not_successfully">No se enviado el código OTP, intenta nuevamente.</string>
<string name="ak_core_otp_not_valid_or_expired">El código OTP no es valido o ha caducado.\nPor favor intenta nuevamente.</string>
<string name="ak_core_otp_not_valid">El código OTP no es valido.</string>