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
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
Key | Value | Description |
---|---|---|
clientKey | String | Unique key of the client |
userKey | String | User ID |
name | String | User name |
verifyType | String | Verification type |
verifyData | String | Verification data (email or phone number) |
Response
Name | Type | Description |
---|---|---|
rtCode | Int | Result code |
rtMsg | String | Result message |
{data} | class | |
data.result | Boolean | Verification result |
data.authType | Int | Authentication 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
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
Name | Value | Description |
---|---|---|
clientKey | String | Unique key of the client |
String | User's email | |
authNum | String | OTP number entered by the user |
Response
Name | Type | Description |
---|---|---|
rtCode | Int | Result code |
rtMsg | String | Result message |
{data} | class | |
data.result | Boolean | Verification result |
data.disposeToken | String | Verification 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
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
Name | Value | Description |
---|---|---|
clientKey | String | Unique key of the client |
phoneNum | String | User's phone number |
authNum | String | OTP number entered by the user |
Response
Name | Type | Description |
---|---|---|
rtCode | Int | Result code |
rtMsg | String | Result message |
{data} | class | |
data.result | Boolean | Verification result |
data.disposeToken | String | Verification 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
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
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
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
Name | Value | Description |
---|---|---|
userKey | String | User ID |
name | String | User name |
phoneNum | String | User's phone number |
String | User's email | |
authType | String | Authentication type |
otpType | String | OTP verification type |
disposeToken | String | Token received after email or SMS verification |
token | String | FCM token |
Response
Name | Type | Description |
---|---|---|
rtCode | Int | Result code |
rtMsg | String | Result message |
If the device re-registration API call is successful, you will receive a `rtCode` of 0.