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.

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

//Amani init with server, sharedSecret, without UploadSource.
Amani.init(this,"SERVER", "SHARED_SECRET")

//Amani init with server, sharedSecret and UploadSource params.
//UploadSource use cases -> [UploadSource.KYC, UploadSource.PASSWORD, UploadSource.VIDEO].
Amani.init(this,"SERVER", "SHARED_SECRET", UploadSource.KYC)

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