Dependencies

Core

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

4.3.8 Latest

Quick start

K

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

implementation 'com.autentikar:core:4.3.8'

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:

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
}

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

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)

inExternalApp

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)
Options

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

account
string
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
string
The flow id that you want to start.
user
User
The user class that will start the flow.
stage
Default to PROD - The stage of the flow that you want to start.
customFields
map<string,any>
The custom fields that you want to send to the flow.
files
map<string,string>
The files that you want to send to the flow, you can add files in base64.
responseType
Default to INSTANCE_RESPONSE - The type of response that the SDK will return to the application.

inExternalApp

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

nextToken
string
The next token is an identifier that allows you to start a flow from an external application.
authToken
string
The auth token is an identifier that allows you validate the app that is starting the flow.
stage
Default to PROD - The stage of the flow that you want to start.

inNextStep

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

nextStepToken
string
The next step token is an identifier that allows you to resume a previous flow.
stage
Default to PROD - The stage of the flow that you want to start.

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

token
string
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
string
The country of the user.
docType
string
The document type of the user.
idNum
string
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:

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

  Options.instanceStatusTimeout = 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

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
          }
      }
  }

inExternalApp

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
          }
      }
  }

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:

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)

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.
<!--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>