Skip to main content

Initializing the SDK

After completing the installation phase, you must initialize the SDK with a profile token from the server and other necessary information.

caution

This init method must be called once before all other methods/modules. If you try to use the modules/methods you'll get a RuntimeException("Amani not initialised") error mesage. In such cases, make sure you have called the init with correct parameters.

note

SHARED_SECRET is a key that ensures and validates the validity/security of the request in network requests. This key will be sent to you confidentially by the Amani team. In cases where you do not provide SharedSecret, the Amani.init() method will still work without any problems. However, requests made in the upload methods will be unsigned. Use SharedSecret to avoid such security situations.

note

UploadSource is used to distinguish uploads from different sources. There are 3 UploadSources in the current version. These are KYC, VIDEO, PASSWORD. If UploadSource is not specified, the default is UploadSource.KYC. If you need to change UploadSource after init; You can also use the Amani.sharedInstance().setUploadSource() method.

note

SSL Pinning: Provides secure networking with SSL pinning activation. It's optional to use configuration, not mandatory. Must be called before the init method. Throws AmaniException in case of invalid certificate. Use in try catch block. _ Amani.setSSLPinning(this, R.raw.pinning_cert)_ method.

        //SSL pinning certfication settings
try {
Amani.setSSLPinning(this, R.raw.ssl_cert)
} catch (e: Exception) {
//Invalid certification
}

//Amani init with only server param.
//When sharedSecret is not given, validity/security of the requests will not be activated.
Amani.init(this,"https://server.example")

//Amani init with server, sharedSecret, without UploadSource.
Amani.init(this,"https://server.example", "optional shared secret")

//Amani init with server, sharedSecret and UploadSource params.
//UploadSource use cases -> [UploadSource.KYC, UploadSource.PASSWORD, UploadSource.VIDEO].
Amani.init(this,"https://server.example", "optional shared secret", UploadSource.KYC)

After the application stands up, the initAmani() function can be called in the flow of a desired screen, depending on the result of initAmani() function other modules will be also available to use. If isSuccess is true as a result of the initAmani() request, other modules can be used. Otherwise, you will get an error from the callback result of the current module. It is enough for initAmani() to be successful once during the lifecycle. The application must be called again when the life cycle ends and a new life cycle starts. (In cases where the user closes and opens the application)


try {
Amani.setSSLPinning(this, R.raw.ssl_pinning_invalid_test)
} catch (e: Exception) {
//Invalid certification
}

Amani.init(this,"https://server.example", "optional shared secret")

Amani.sharedInstance()
.initAmani(
requireActivity(),
"ID_NUMBER",
"TOKEN",
"LANGUAGE e.g. tr")
{ isSuccess: Boolean ->

if (isSuccess) {
//The request is successful, all other modules are ready to use.
} else {
//The request failed, due to error : $errorCode, other modules cannot
//Other modules cannot be used until the request is successful.
}
}

Setting up the event listeners

You can listen the profileStatus and stepResult events for the specific changes. To do this, you can call the setEventListener method with AmaniEventCallBack object.

Amani.sharedInstance().AmaniEvent().setListener(object : AmaniEventCallBack {
override fun onError(type: String?, error: ArrayList<AmaniError?>?) {
//Error happened
}

override fun profileStatus(profileStatus: ProfileStatus) {
//Profile status changed
}

override fun stepsResult(stepsResult: StepsResult?) {
//Steps are changed, you can check the list of steps
}
})

Profile Status

KeyTypeDescription
amlStatusbooleanAnti Money Laundering
riskIntRange: 0-4. Shows the risk status of the profile
statusStringShows the general status of the profile, such as APPROVED, REJECTED, or PENDING
profileStringReturns the UUID of the profile the user is connected to

Steps Result

KeyTypeDescription
resultArrayList of ResultReturns the list of steps in the profile as an array list
idStringReturns the unique ID of the step
titleStringReturns the unique title of the related step (example: Selfie, Identification) NOTE: Title is editable, if you want to manipulate the title cummunicate with Amani Mobile Team.
statusStringShows the related step status of the profile, such as APPROVED, REJECTED, or PENDING.
sortOrderIntOrdering number of the related step for purpose of the ordering the related step into UI
errorsList of ErrorsErrors of the related steps happened during the process

On Error

KeyTypeDescription
typeStringCurrent error type as String
errorArrayList of AmaniErrorReturns the list of the AmaniError

Types

Error TypesDescription
login_errorCurrent error type as String
config_errorErrors related with fetching remote config
selfie_errorErrors related with Selfie upload process
id_errorErrors related with ID upload process
signature_errorErrors related with Signature upload process
customer_errorErrors related with Customer service fetch&po
socket_errorGeneral socket errors
nfc_errorErrors related with NFC read

Errors

Error CodeError Message
10904MRZ result is null/empty
10404Selfie should be taken before upload called
10809Back image could not found
10808Response data is null/empty
10502SSL Pinning Error
10604SSL Certificate Exception
10500Please check your internet connection
10600General exception during upload