accounts

Accounts SDK for Android

The Accounts SDK is a solution to ease the integration with the Alviere services.

Features

  • User Account Management

  • User Addresses Management

  • User Contacts Management

  • User Documents Management

Requirements

  • Android Studio 4.0 or above

  • Android 5.0 (API level 21) or above

  • Java 8+

Integration

1. Get the latest versions of accounts.aar and alcore.aar, and open up the project structure by right-clicking on your project and choosing Open Module Settings or choosing File Project Structure…. Click the + button in the top left to add a new module.

image

2. Choose Import .JAR/.AAR Package and click the Next button.

image

3. Find your accounts.aar file using the folder button beside the File name field. Android Studio will automatically create a subproject name. Just click Finish and repeat the process for the alcore.aar file.

image

4. Gradle will sync, which may take a few minutes. You should have the following implementation statements on your module's build.gradle file. Please note that sometimes Android Studio generates these statements on the project's build.gradle file. In that case, move them to the module's one.

...
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
...
implementation project(path: ':alcore')
implementation project(path: ':accounts')
}

5. Make sure you have enabled Java 8 language feature support. To do so, guarantee that the following configurations are on the module's build.gradle file.

...
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

6. Now that you have added the .aar modules, you need to add its dependencies as shown below. Once complete, sync gradle again.

apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
...
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
...
implementation project(path: ':alcore')
implementation project(path: ':accounts')
...
}

Usage

Before you can use the Accounts Sdk, and if you want to call the user management services you need to first setup the environment on AccountsSdk. Keep in mind that the process of setting up the environment is asynchronous, so you should set it as soon as possible.

AccountsSdk.create()

User Account Management

This section outlines the integration with Alviere to create and manage your customers and users.

Declare the callback

The AccountUserCallback callback is the main communication back channel to your application. For each action there is one method associated as follows. In addition to these methods, there is also an event method for handling events. Callbacks will always run on main thread.

private val accountUserCallback = object : AccountUserCallback {
override fun onAddUserSuccess(userAccount: UserAccountModel) { /* handle success */ }

override fun onDeleteUserSuccess() { /* handle success */ }

override fun onGetUserSuccess(userAccount: UserAccountModel) { /* handle success */ }

override fun onUpdateUserSuccess(userAccount: UserAccountModel) { /* handle success */ }

override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}
onSuccess

This callback method is called when an user has successfully create or manage the user account. Use this to upload and store the user account with your service for use with the Alviere API.

onEvent

This callback method is called when the user exited from the Accounts SDK, when an error occurred, or when certain events in the Accounts SDK flow have occurred. This allows your application to get more information about what is going on as the user goes through the Accounts SDK flow. In case of an error, you may want to display information related to the error to the user and have them try doing the action again.

Get User Account

To obtain an user account, use the Accounts Sdk service method AccountsSdk.getUserAccount. Pass the session_token, the account_uuid and the AccountUserCallback.

AccountsSdk.getUserAccount(
sessionToken = session_token,
accountUuid = account_uuid,
callback = accountUserCallback
)

The result of this action will return the specific UserAccountModel on onGetUserSuccess(userAccount: UserAccountModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Update User Account

To update an user account, use the Accounts Sdk service method AccountsSdk.updateUserAccount. Pass the session_token, the account_uuid, the UpdateUserAccountModel model and the AccountUserCallback.

val model = UpdateUserAccountModel( ... )
AccountsSdk.getUserAccount(
sessionToken = session_token,
accountUuid = account_uuid,
data = model,
callback = accountUserCallback
)

The result of this action will return the updated UserAccountModel on onUpdateUserSuccess(userAccount: UserAccountModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Delete User Account

To delete an user account, use the Accounts Sdk service method AccountsSdk.deleteUserAccount. Pass the session_token, the account_uuid, and the AccountUserCallback.

AccountsSdk.deleteUserAccount(
sessionToken = session_token,
accountUuid = account_uuid,
callback = accountUserCallback
)

The result of this action will return on onDeleteUserSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

User Addresses Management

This section outlines the integration with Alviere to create and manage your customers and users addresses.

Declare the callback

The AccountAddressCallback callback is the main communication back channel to your application. For each action there is one method associated as follows. In addition to these methods, there is also an event method for handling events. Callbacks will always run on main thread.

private val accountAddressCallback = object : AccountAddressCallback {
override fun onAddAddressSuccess(userAddress: UserAddressModel) { /* handle success */ }

override fun onDeleteAddressSuccess() { /* handle success */ }

override fun onGetAddressSuccess(userAddressesList: List<UserAddressModel>) { /* handle success */ }

override fun onUpdateAddressSuccess(userAddress: UserAddressModel) { /* handle success */ }

override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle events */ }
}
onSuccess

This callback method is called when an user has successfully create or manage the user account address. Use this to upload and store the user account with your service for use with the Alviere API.

onEvent

This callback method is called when the user exited from the Accounts SDK, when an error occurred, or when certain events in the Accounts SDK flow have occurred. This allows your application to get more information about what is going on as the user goes through the Accounts SDK flow. In case of an error, you may want to display information related to the error to the user and have them try doing the action again.

Add User Account Address

To add an user account address, use the Accounts Sdk service method AccountsSdk.addAddress. Pass the session_token, the AddAddressRequestModel model and the AccountAddressCallback.

val model = AddAddressRequestModel( ... )
AccountsSdk.addAddress(
sessionToken = session_token,
data = model,
callback = accountAddressCallback
)

The result of this action will return the newly created UserAddressModel on onAddAddressSuccess(userAddress: UserAddressModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Get User Account Address

To obtain an user account address, use the Accounts Sdk service method AccountsSdk.getAddress. Pass the session_token, the account_uuid and the AccountAddressCallback.

AccountsSdk.getAddress(
sessionToken = session_token,
accountUuid = account_uuid,
callback = accountAddressCallback
)

The result of this action will return the user's addresses List<UserAddressModel> on onGetAddressSuccess(userAddressesList: List<UserAddressModel>) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Update User Account Address

To update an user account address, use the Accounts Sdk service method AccountsSdk.updateAddress. Pass the session_token, the account_uuid, the address_id, the UpdateAddressModel model and the AccountAddressCallback.

val model = UpdateAddressModel( ... )
AccountsSdk.updateAddress(
sessionToken = session_token,
accountUuid = account_uuid,
addressId = address_id,
data = model,
callback = accountAddressCallback
)

The result of this action will return the updated UserAddressModel on onUpdateAddressSuccess(userAddress: UserAddressModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Delete User Account Address

To delete an user account address, use the Accounts Sdk service method AccountsSdk.deleteAddress. Pass the session_token, the account_uuid, and the AccountAddressCallback.

AccountsSdk.deleteAddress(
sessionToken = session_token,
accountUuid = account_uuid,
addressId = address_id,
callback = accountAddressCallback
)

The result of this action will return on onDeleteAddressSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

User Contacts Management

This section outlines the integration with Alviere to create and manage your customers and users contacts.

Declare the callback

The AccountContactCallback callback is the main communication back channel to your application. For each action there is one method associated as follows. In addition to these methods, there is also an event method for handling events. Callbacks will always run on main thread.

private val accountContactCallback = object : AccountContactCallback {
override fun onAddContactSuccess(userContact: UserContactModel) { /* handle success */ }

override fun onDeleteContactSuccess() { /* handle success */ }

override fun onGetContactSuccess(userContacts: List<UserContactModel>) { /* handle success */ }

override fun onUpdateContactSuccess(userContact: UserContactModel) { /* handle success */ }

override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle events */ }
}
onSuccess

This callback method is called when an user has successfully create or manage the user account contacts. Use this to upload and store the user account with your service for use with the Alviere API.

onEvent

This callback method is called when the user exited from the Accounts SDK, when an error occurred, or when certain events in the Accounts SDK flow have occurred. This allows your application to get more information about what is going on as the user goes through the Accounts SDK flow. In case of an error, you may want to display information related to the error to the user and have them try doing the action again.

Add User Account Contact

To add an user account address, use the Accounts Sdk service method AccountsSdk.addContact. Pass the session_token, the AddContactModel model and the AccountContactCallback.

val model = AddContactModel( ... )
AccountsSdk.addAddress(
sessionToken = session_token,
data = model,
callback = accountContactCallback
)

The result of this action will return the newly created UserContactModel on onAddContactSuccess(userContact: UserContactModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Get User Account Contact

To obtain an user account contact, use the Accounts Sdk service method AccountsSdk.getContact. Pass the session_token, the account_uuid and the AccountContactCallback.

AccountsSdk.getAddress(
sessionToken = session_token,
accountUuid = account_uuid,
callback = accountContactCallback
)

The result of this action will return the user's contacts List<UserContactModel> on onGetContactSuccess(userContacts: List<UserContactModel>) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Update User Account Contact

To update an user account contact, use the Accounts Sdk service method AccountsSdk.updateContact. Pass the session_token, the account_uuid, the contact_id, the UpdateContactModel model and the AccountContactCallback.

val model = UpdateContactModel( ... )
AccountsSdk.updateContact(
sessionToken = session_token,
accountUuid = account_uuid,
contactId = contact_id,
data = model,
callback = accountContactCallback
)

The result of this action will return the updated UserContactModel on onUpdateContactSuccess(userContact: UserContactModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Delete User Account Contact

To delete an user account contact, use the Accounts Sdk service method AccountsSdk.deleteContact. Pass the session_token, the account_uuid, the contact_id and the AccountContactCallback.

AccountsSdk.deleteContact(
sessionToken = session_token,
accountUuid = account_uuid,
contactId = contact_id,
callback = accountContactCallback
)

The result of this action will return on onDeleteContactSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

User Documents Management

This section outlines the integration with Alviere to create and manage your customers and users documents.

Declare the callback

The AccountDocumentCallback callback is the main communication back channel to your application. For each action there is one method associated as follows. In addition to these methods, there is also an event method for handling events. Callbacks will always run on main thread.

private val accountDocumentCallback = object : AccountDocumentCallback {
override fun onAddDocumentSuccess() { /* handle success */ }

override fun onDeleteDocumentSuccess() { /* handle success */ }

override fun onUpdateDocumentSuccess() { /* handle success */ }

override fun onGetDocumentsSuccess(userDocument: UserDocumentFileModel) { /* handle success */ }

override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle events */ }
}
onSuccess

This callback method is called when an user has successfully create or manage the user account documents. Use this to upload and store the user account with your service for use with the Alviere API.

onEvent

This callback method is called when the user exited from the Accounts SDK, when an error occurred, or when certain events in the Accounts SDK flow have occurred. This allows your application to get more information about what is going on as the user goes through the Accounts SDK flow. In case of an error, you may want to display information related to the error to the user and have them try doing the action again.

Add User Account Documents

// TO BE IMPLEMENTED

Get User Account Documents

To obtain an user account document, use the Accounts Sdk service method AccountsSdk.getUserDocument. Pass the session_token, the account_uuid, the document_id and the AccountDocumentCallback.

AccountsSdk.getUserDocument(
sessionToken = session_token,
accountUuid = account_uuid,
documentId = document_id,
callback = accountDocumentCallback
)

The result of this action will return the specific UserDocumentFileModel on onGetDocumentsSuccess(userDocument: UserDocumentFileModel) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Update User Account Documents

// TO BE IMPLEMENTED

Delete User Account Documents

To delete an user account document, use the Accounts Sdk service method AccountsSdk.deleteUserDocument. Pass the session_token, the account_uuid, the document_id and the AccountDocumentCallback.

AccountsSdk.deleteUserDocument(
sessionToken = session_token,
accountUuid = account_uuid,
documentId = document_id,
callback = accountDocumentCallback
)

The result of this action will return on onDeleteDocumentSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Customization

The Accounts SDK for Android provides a set of UI styling customizations to allow you to adjust the provided UI to fit your needs. To customize the UI, you can use the AccountsCustomize object or override the colors.xml, strings.xml and dimens.xml values.

Customize Object

To start using AccountsCustomize set the object using Accounts.setCustomize. This will override some of the colors.xml, strings.xml and dimens.xml values.

.------------------------.--------------------.------------------------------------.
| Class | Attribute | Description |
:------------------------+--------------------+------------------------------------:
| AccountsCustomize | documentsCustomize | DocumentsCustomize resource keys |
| :--------------------+------------------------------------:
| | loadingCustomize | LoadingCustomize resource keys |
| '--------------------'------------------------------------'
| | tryAgainCustomize | TryAgainCustomize resource keys |
'------------------------'--------------------'------------------------------------'

Colors

The Accounts SDK for Android allows you to customize the UI colors. To do so, you will need to override the color key that you want to change on your colors.xml file. Below is a list of the current color keys.

.-----------------------------------------------------------------.---------------------------------.
| Key | Accounts Customize Support |
:-----------------------------------------------------------------+---------------------------------:
| alviere_sdk_accounts_try_again_background | Yes |
:-----------------------------------------------------------------+---------------------------------:
| alviere_sdk_accounts_try_again_error_message_text_color | Yes |
:-----------------------------------------------------------------+---------------------------------:
| alviere_sdk_accounts_try_again_button_background | Yes. Changing Drawable. | |
:-----------------------------------------------------------------+---------------------------------:
| alviere_sdk_accounts_try_again_button_background_pressed | Yes. Changing Drawable. |
:-----------------------------------------------------------------+---------------------------------:
| alviere_sdk_accounts_try_again_button_text | Yes |
:-----------------------------------------------------------------+---------------------------------'

.-----------------------------------------------------------------.---------------------------------.
| alviere_sdk_accounts_loading_background | Yes |
:-----------------------------------------------------------------+---------------------------------+
| alviere_sdk_accounts_loading_bar | Yes |
:-----------------------------------------------------------------+---------------------------------+
| alviere_sdk_accounts_loading_message | Yes |
'-----------------------------------------------------------------'---------------------------------'

Text and Localization

The Accounts SDK for Android allows you to customize the UI text. To do so, you will need to override the string key that you want to change on your strings.xml file. The next section details a list of the current localization keys. Currently, the SDK only provides english localization.

.-----------------------------------------------------------------.------------------------------.---------------------------------.
| Key | English Value | Accounts Customize Support |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_title_driver_license_front | Driver License Front | Yes |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_title_driver_license_back | Driver License Back | Yes |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_title_passport | Passport | Yes |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_title_proof_of_address | Proof of address | Yes |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_title_selfie | Face | Yes |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_step | Step %1$d of %2$d | Yes |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_retake | Take a new one | Yes |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_accept_photo | Yes | Yes |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_is_photo_ok | Looking good? | Yes |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_documents_uploading | Uploading | Yes |
'-----------------------------------------------------------------'------------------------------'---------------------------------'

.-----------------------------------------------------------------.------------------------------.---------------------------------.
| alviere_sdk_accounts_facialcapture_hint_no_face | No face detected | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_facialcapture_hint_multiple_faces | Multiple faces detected | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_facialcapture_hint_face_center | Center Face In The Oval | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_facialcapture_hint_get_farther | Get farther | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_facialcapture_hint_get_closer | Get closer | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_facialcapture_hint_smile | Smile | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_facialcapture_hint_stop_smiling | Stop smiling | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_facialcapture_hint_press_capture_button | Press button when ready | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_facialcapture_hint_hold_still | Hold Still | No |
'-----------------------------------------------------------------'------------------------------'---------------------------------'

.-----------------------------------------------------------------.------------------------------.---------------------------------.
| alviere_sdk_accounts_misnap_hint_too_dim | Too dim | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_too_bright | Too bright | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_hold_steady | Hold Still | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_too_far | Too far | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_too_close | Too close | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_angle_too_large | Angle too large | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_angle_rotation | Reduce rotation | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_glare | Reduce glare | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_busy_background | Busy background | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_low_contrast | Low contrast | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_wrong_document | Center the document | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_not_check_back | Not check back | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_misnap_hint_not_check_front | Not check front | No |
'-----------------------------------------------------------------'------------------------------'---------------------------------'

.-----------------------------------------------------------------.------------------------------.---------------------------------.
| alviere_sdk_accounts_try_again_error_message | An error has occurred | No |
:-----------------------------------------------------------------+------------------------------+---------------------------------:
| alviere_sdk_accounts_try_again_error_button_text | Try again | No |
'-----------------------------------------------------------------'------------------------------'---------------------------------'

Dimensions

The Accounts SDK for Android allows you to customize the UI dimensions. To do so, you will need to redefine the localization key that you want to change on your dimens.xml file. The next section details a list of the current localization keys.

.-----------------------------------------------------------------.----------------------------.
| Key | Accounts Customize Support |
.-----------------------------------------------------------------.----------------------------.
| alviere_sdk_accounts_documents_title | Yes |
'-----------------------------------------------------------------+----------------------------'
| alviere_sdk_accounts_documents_subtitle | Yes |
'-----------------------------------------------------------------+----------------------------'

:-----------------------------------------------------------------+----------------------------:
| alviere_sdk_accounts_try_again_button_margin_start | Yes |
:-----------------------------------------------------------------+----------------------------:
| alviere_sdk_accounts_try_again_button_margin_end | Yes |
:-----------------------------------------------------------------+----------------------------:
| alviere_sdk_accounts_try_again_button_margin_bottom | Yes |
:-----------------------------------------------------------------+----------------------------:
| alviere_sdk_accounts_try_again_button_margin_top | Yes |
:-----------------------------------------------------------------+----------------------------:
| alviere_sdk_accounts_try_again_button_corner_radius | Yes. Changing Drawable. |
:-----------------------------------------------------------------+----------------------------:
| alviere_sdk_accounts_try_again_button_text_size | Yes |
:-----------------------------------------------------------------+----------------------------:
| alviere_sdk_accounts_try_again_message_text_size | Yes |
'-----------------------------------------------------------------'----------------------------'

.-----------------------------------------------------------------.----------------------------.
| alviere_sdk_accounts_loading_text_size | Yes |
'-----------------------------------------------------------------+----------------------------'

Packages

com.alviere.android.accounts
Link copied to clipboard
com.alviere.android.accounts.customize
Link copied to clipboard