Skip to content

Device Re-registration

This guide explains how to deregister and re-register a device with the BSA via the Android SDK.

If a user who was using BSA changes their mobile device, the device re-registration feature allows them to use BSA authentication as before by verifying member information and re-registering the device. First, the membership status is checked, and then an OTP code is sent via email for member verification, followed by re-registration.

First, the membership status is checked, and then an OTP code is sent via email for member verification, followed by re-registration.

i. User Check and OTP Dispatch

Request for user check and OTP dispatch. Use BsaSdk's sendOtpByRegisterDevice() to request the API. If the entered user information is correct, an OTP code will be sent to the email.

Example

kotlin
val params : HashMap<String, Any> = HashMap()  
params["clientKey"] = "{clientKey}"
params["userKey"] = "{userKey}"
params["name"] = "{name}"
params["verifyType"] = SdkConstant.OtpType.EMAIL.value
params["verifyData"] = "{email}"
// or for SMS
// params["verifyType"] = SdkConstant.OtpType.SMS.value
// params["verifyData"] = "{phoneNum}"

BsaSdk.getInstance().sdkService.sendOtpByRegisterDevice(params, object: SdkResponseCallback<SendOtpResponse> {
	override fun onSuccess(result: SendOtpResponse?) {  
		...
	}
	override fun onFailed(errorResult: ErrorResult?) {  
		...
	}
})

Parameter

KeyValueDescription
clientKeyStringUnique key of the client
userKeyStringUser ID
nameStringUser name
verifyTypeStringVerification type
verifyDataStringVerification data (email or phone number)

Response

NameTypeDescription
rtCodeIntResult code
rtMsgStringResult message
{data}class
data.resultBooleanVerification result
data.authTypeIntAuthentication type

ii. Email Verification Confirmation

Use the seq result value from sendOtpByEmail(), the registration verification code displayed in the email, and input the email to confirm email verification. To confirm email verification, request the API using BsaSdk's verifyOtpByEmail(). If the registration verification code is valid, the token for registration will be provided. Example

kotlin
val params : HashMap<String, Any> = HashMap()  
params["clientKey"] = "{CLIENT_KEY}"  
params["email"] = "{email}"  
params["authNum"] = "{authNumber}"

BsaSdk.getInstance().sdkService.verifyOtpByEmail(params, object: SdkResponseCallback<VerifyOtpResponse> {
    override fun onSuccess(result: VerifyOtpResponse?) {  
		...
	}
	override fun onFailed(errorResult: ErrorResult?) {  
		...  
	}  
})

Parameter

NameValueDescription
clientKeyStringUnique key of the client
emailStringUser's email
authNumStringOTP number entered by the user

Response

NameTypeDescription
rtCodeIntResult code
rtMsgStringResult message
{data}class
data.resultBooleanVerification result
data.disposeTokenStringVerification token

iii. SMS Verification Confirmation

Use the seq result value from sendOtpBySms(), the registration verification code displayed in the email, and input the email to confirm email verification. To confirm email verification, request the API using BsaSdk's verifyOtpBySms(). If the registration verification code is valid, the token for registration will be provided.

Example

kotlin
val params : HashMap<String, Any> = HashMap()  
params["clientKey"] = "{CLIENT_KEY}"  
params["phoneNum"] = "{phoneNumber}"  
params["authNum"] = "{authNumber}"

BsaSdk.getInstance().sdkService.verifyOtpBySms(params, object: SdkResponseCallback<VerifyOtpResponse> {
    override fun onSuccess(result: VerifyOtpResponse?) {  
		...
	}
	override fun onFailed(errorResult: ErrorResult?) {  
		...  
	}  
})

Parameter

NameValueDescription
clientKeyStringUnique key of the client
phoneNumStringUser's phone number
authNumStringOTP number entered by the user

Response

NameTypeDescription
rtCodeIntResult code
rtMsgStringResult message
{data}class
data.resultBooleanVerification result
data.disposeTokenStringVerification token

iv. Local Authentication

This is a mandatory step for authenticating the device using the previously registered local authentication method.

This is a method for registering biometric authentication information.
Example

kotlin
BsaSdk.getInstance().sdkService.registerBiometric(fragmentActivity, object: SdkResponseCallback<AuthBiometricResponse> {
	override fun onSuccess(authBiometric: AuthBiometricResponse?) {
		// Code to execute after registration
		...
	}
	override fun onFailed(errorResult: ErrorResult?) {
		...
	}
})

This is a method for device authentication or registering device authentication information(PIN, pattern).
Example

kotlin
BsaSdk.getInstance().sdkService.authDeviceCredential(fragmentActivity, object : SdkResponseCallback<AuthBiometricResponse> {
	override fun onSuccess(authBiometric: AuthBiometricResponse?) {
		// Code to execute after successful password/pattern authentication
		...
	}
	override fun onFailed(errorResult: ErrorResult?) {
		...
	}
})

v. Device Re-registration

Request the device re-registration API using BsaSdk's reRegisterUserDevice(). You need the token verified through verifyOtpByEmail(), and after the re-registration process is completed, you can use BSA authentication as before.

Example

kotlin
val params: MutableMap<String, Any> = HashMap()  
params["userKey"] = "{userKey}"
params["name"] = "{name}"
params["phoneNum"] = "{phoneNum}"
params["email"] = "{email}"
params["authType"] = "{authType}"
params["otpType"] = "{email}" // or for SMS it's "{sms}"
params["disposeToken"] = "{disposeToken}"

FirebaseMessaging.getInstance().token.addOnSuccessListener { token ->  
    params["token"] = token
}

BsaSdk.getInstance().sdkService.reRegisterUserDevice(map, object: SdkResponseCallback<ReRegisterDeviceResponse> {
	override fun onSuccess(result: SendOtpResponse?) {  
		...
	}
	override fun onFailed(errorResult: ErrorResult?) {  
		...
	}  
})

Parameter

NameValueDescription
userKeyStringUser ID
nameStringUser name
phoneNumStringUser's phone number
emailStringUser's email
authTypeStringAuthentication type
otpTypeStringOTP verification type
disposeTokenStringToken received after email or SMS verification
tokenStringFCM token

Response

NameTypeDescription
rtCodeIntResult code
rtMsgStringResult message
If the device re-registration API call is successful, you will receive a `rtCode` of 0.