Initializing the SDK
After completing the installation phase, you must initialize the SDK with a profile token from the server and other necessary information.
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.
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.
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.
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
Key | Type | Description |
---|---|---|
amlStatus | boolean | Anti Money Laundering |
risk | Int | Range: 0-4. Shows the risk status of the profile |
status | String | Shows the general status of the profile, such as APPROVED, REJECTED, or PENDING |
profile | String | Returns the UUID of the profile the user is connected to |
Steps Result
Key | Type | Description |
---|---|---|
result | ArrayList of Result | Returns the list of steps in the profile as an array list |
id | String | Returns the unique ID of the step |
title | String | Returns 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. |
status | String | Shows the related step status of the profile, such as APPROVED, REJECTED, or PENDING. |
sortOrder | Int | Ordering number of the related step for purpose of the ordering the related step into UI |
errors | List of Errors | Errors of the related steps happened during the process |
On Error
Key | Type | Description |
---|---|---|
type | String | Current error type as String |
error | ArrayList of AmaniError | Returns the list of the AmaniError |
Types
Error Types | Description |
---|---|
login_error | Current error type as String |
config_error | Errors related with fetching remote config |
selfie_error | Errors related with Selfie upload process |
id_error | Errors related with ID upload process |
signature_error | Errors related with Signature upload process |
customer_error | Errors related with Customer service fetch&po |
socket_error | General socket errors |
nfc_error | Errors related with NFC read |
Errors
Error Code | Error Message |
---|---|
10904 | MRZ result is null/empty |
10404 | Selfie should be taken before upload called |
10809 | Back image could not found |
10808 | Response data is null/empty |
10502 | SSL Pinning Error |
10604 | SSL Certificate Exception |
10500 | Please check your internet connection |
10600 | General exception during upload |