Android SDK Migration
warning
To upgrade to Core AmaniSDK v3, you need to use it with the AmaniUI package.
Amani SDK Initialization
- SDK V1
- Amani UI
Amani.init(this,"server","SHARED_SECRET"); // WARNING! It must be called at least once before other functions are called.
// If you want to disable Signature, leave SHARED_SECRET as empty.
// SHARED_SECRET will be provided from Amani if needed.
Amani.goToKycActivity(
this,
"ENTER TCIN NO HERE", //(Can not be null or empty)
"ENTER TOKEN HERE", //(Can not be null or empty)
"ENTER BIRTH DATE HERE", // YYMMDD format. (For Example: 20 May 1990 is 900520). (Can be empty if NFC is not used.)
"ENTER EXPIRE DATE HERE", // YYMMDD format.(Can be empty if NFC is not used.)
"ENTER DOCUMENT NO HERE", // Document number of your ID card. (Can be empty if NFC is not used.)
"ENTER GEOLOCATION PERMISSION", // Boolean value of your geoLocation value(true/false). (Default value: true)
"ENTER LANGUAGE", // Language of your current application. (tr,en,zh etc.) (Default value: "tr")
"ENTER USER's EMAIL", // Must be in EMAIL format! (@Nullable or empty if not needed.)
"ENTER USER's PHONE NUMBER", // Phone number of user. (@Nullable or empty if not needed.)
"ENTER FULL NAME OF USER" // Full name of user. (@Nullable or empty if not needed.)
);
On Activity Result
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
//Getting verification status true/false as boolean return.
val verificationCompleted = Objects.requireNonNull(data)!!.getBooleanExtra("ON_SUCCESS", false)
//Getting token status true/false as boolean return.
val tokenExpired = Objects.requireNonNull(data)!!.getBooleanExtra("TOKEN_EXPIRED", false)
//Getting network connection true/false
val networkError = Objects.requireNonNull(data)!!.getBooleanExtra("ON_NETWORK_ERROR", false)
//Getting HTTPS's error codes if there is any API exception.
val apiException = Objects.requireNonNull(data)!!.getIntExtra("ON_API_EXCEPTION", 10000)
//Getting list of KYC steps's information.
try {
var stepList: Map<String, String>? = null
stepList = SessionManager.getRules()
}catch (e: Exception) {
Log.d("TAG", "onActivityResult: stepList is null")}
if (verificationCompleted) {
//Do something!
}
if (tokenExpired) {
//Your token is expired.
}
if (networkError){
// Check your internet connection, please.
}
if (apiException == 401) // HTTPS Error: 401
//... //HTPS Error: apiException
//... //HTPS Error: apiException
//... //HTPS Error: apiException
}
AmaniSDKUI.init(
activity = this,
serverURL = TestCredentials.SERVER_URL,
amaniVersion = AmaniVersion.V2,
sharedSecret = null
)
AmaniSDKUI.goToKycActivity(
activity = this, //Activity pointer
resultLauncher = resultLauncher, //Requires for listening the activity result, sample resultLauncher is below
idNumber = ID_CARD_NUMBER,
authToken = AUTH_TOKEN_FOR_SECURITY,
language = "tr",
geoLocation = true, //Giving permission to access SDK user's location data to process that data
birthDate = BIRTH_DATE, //YYMMDD format. (For Example: 20 May 1990 is 900520). If NFC not used not mandatory
expireDate = EXPIRE_DATE, //YYMMDD format. Expire date of SDK user's ID Card, If NFC not used not mandatory
documentNumber = DOCUMENT_NUMBER, // Document number of SDK user's ID Card, If NFC not used not mandatory
userEmail = "test@gmail.com", // Email of the SDK user, non mandatory field
userPhoneNumber = PHONE_NUMBER //Phone number of the SDK user, non mandatory field,
userFullName = FULL_NAME //Full name of the SDK user, non mandatory field
)
Register For Activity Result
private val resultLauncher = this.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val data: Intent? = result.data
data?.let {
//Result of the KYC process
val kycResult: KYCResult? = it.parcelable(AppConstant.KYC_RESULT)
}
}
}
You can get more detailed information about the messages coming from AmaniUI Listeners from this link. Profile Status