User Registration
iOS SDK provides featured to register and use BSA_SDK by using basic information.
i. Duplicated Registered Information (Check email and phone number)
Check if there is any duplicated email and phone number before BSA registration process. It requests API by BSA.APICaller.checkDuplicateUserData of BSA_SDK. Whether user information is unique or not can be identified upon the verifyType.
To check for duplicate emails, set verifyType to Email and put the email address in verifyData.
To check for duplicate phone numbers, set verifyType to PhoneNumber and put the phone number in verifyData.
Example
BSA.APICaller.checkDuplicateUserData(verifyData: "user@email.com",
verifyType: .Email,
onNotDulplicateUser: { [weak self] in
// When Not Duplicate
}, onDulplicateUser: { [weak self] in
// When Duplicate
}, onFailed: { [weak self] rtCode, resultMessage in
// Invocation Failure
}, onError: { [weak self] error in
// Invocation Error
}, onTotalLog: { text in
// Invocation Log
}, onCompleted: {
// invocation completed
}, disposeBag: disposeBag)
Parameter
BSA.APICaller.checkDuplicateUserData(verifyData: String,
verifyType: BSA.Enums.VerifyType,
onNotDulplicateUser: @escaping () -> (),
onDulplicateUser: @escaping () -> (),
onFailed: @escaping OnFailed,
onError: @escaping OnError,
onTotalLog: @escaping OnTotalLog? = nil,
onCompleted: @escaping onCompleted? = nil,
disposeBag: DisposeBag )
Parameter | Type | Description |
---|---|---|
verifyData | String | Data for duplicate checking (email, phoneNumber). |
verifyType | BSA.Enums.VerifyType | Duplicate check type (Email, PhoneNumber). |
onNotDuplicateUser | () -> () | Callback function called when data is not duplicate. |
onDuplicateUser | () -> () | Callback function called when data is duplicate. |
onFailed | OnFailed | Callback function called on API processing failure. |
onError | OnError | Callback function called on error. |
onTotalLog | OnTotalLog | Callback function to receive all logs generated during API calls. |
onCompleted | onCompleted | Called at the end after all processes are completed. |
disposeBag | DisposeBag | DisposeBag variable to manage RxSwift Disposable objects. |
ii. OTP Number Request
Use the clientKey obtained when requesting SDK usage. If the call is successful, you can receive the OTP number via email/sms.
API : BSA.APICaller.requestOTPNumberSendExample
BSA.APICaller.requestSendOTPNumber(sendType: .Email,
sendTarget: "user@email.com",
clientKey: "a1hrg2xv...",
bundleIdentifier: "com.your.app",
onSuccess: {
// Successful Request for OTP Number Transmission
}, onFailed: { [weak self] rtCode, resultMessage in
// Invocation Failure
}, onError: { [weak self] error in
// Invocation Error
}, onTotalLog: { text in
// Invocation Log
}, onCompleted: {
// invocation completed
}, disposeBag: disposeBag)
Parameter
BSA.APICaller.requestSendOTPNumber(sendType: BSA.APICaller.OTPSendType,
sendTarget: String,
clientKey: String,
bundleIdentifier: String,
onSuccess: @escaping () -> (),
onFailed: @escaping OnFailed,
onError: @escaping OnError,
onTotalLog: @escaping OnTotalLog? = nil,
onCompleted: @escaping onCompleted? = nil,
disposeBag: DisposeBag )
Parameter | Type | Description |
---|---|---|
sendType | BSA.APICaller.OTPSendType | Platform to receive OTP number (Email, SMS) |
sendTarget | String | Address for OTP number type |
bundleIdentifier | String | App's bundleIdentifier |
onSuccess | () -> () | Callback called on success. |
onFailed | OnFailed | Callback function called on API processing failure. |
onError | OnError | Callback function called on error. |
onTotalLog | OnTotalLog | Callback function to receive all logs generated during API calls. |
onCompleted | onCompleted | Called at the end after all processes are completed. |
disposeBag | DisposeBag | DisposeBag variable to manage RxSwift Disposable objects. |
iii. OTP Number Validation
Enter the OTP number received by email/sms, call the API, and if successful, receive the disposeToken string. disposeToken is used to check whether the user is the correct user during SignUp.
API : BSA.APICaller.verifyOTPNumberExample
BSA.APICaller.verifyOTPNumber(sendType: BSA.APICaller.OTPSendType,
sendTarget: String,
otpNumber: "298336",
clientKey: "a1hrg2xv...",
onValidOTPNumber: { [weak self] disposeToken in
// OTP Number Matches
// Token Storage
self?.data.disposeToken = disposeToken
}, onInvalidOTPNumber: {
// OTP Number Doesn't Match
}, onFailed: { [weak self] rtCode, resultMessage in
// Invocation Failure
}, onError: { [weak self] error in
// Invocation Error
}, onTotalLog: { text in
// Invocation Log
}, onCompleted: {
// invocation completed
}, disposeBag: disposeBag)
Parameter
BSA.APICaller.verifyOTPNumber(sendType: BSA.APICaller.OTPSendType,
sendTarget: String,
otpNumber: String,
clientKey: String,
onValidOTPNumber: @escaping (String) -> (),
onInvalidOTPNumber: @escaping () -> (),
onFailed: @escaping OnFailed,
onError: @escaping OnError,
onTotalLog: @escaping OnTotalLog? = nil,
onCompleted: @escaping onCompleted? = nil,
disposeBag: DisposeBag )
Parameter | Type | Description |
---|---|---|
sendType | BSA.APICaller.OTPSendType | Platform to receive OTP number (Email, SMS) |
sendTarget | String | Address for OTP number type |
otpNumber | String | Received OTP number. |
clientKey | String | Client's unique Key |
onValidOTPNumber | (String) -> () | Callback called when OTP numbers match. The disposeToken value passed as a parameter is used in SignUp. |
onInvalidOTPNumber | () -> () | Callback called when OTP numbers don't match. |
onFailed | OnFailed | Callback function called on API processing failure. |
onError | OnError | Callback function called on error. |
onTotalLog | OnTotalLog | Callback function to receive all logs generated during API calls. |
onCompleted | onCompleted | Called at the end after all processes are completed. |
disposeBag | DisposeBag | DisposeBag variable to manage RxSwift Disposable objects. |
iv. Check Available ID
Used to validate the UserID required during SignUp.
API : BSA.APICaller.checkUserKeyAvailableExample
BSA.APICaller.checkUserKeyAvailable(userKey: "user1",
onUserKeyAvailable: {
// User Key Is Usable
}, onUserKeyNotAvailable: {
// User Key Is Not Usable
}, onFailed: { [weak self] rtCode, resultMessage in
// Invocation Failure
}, onError: { [weak self] error in
// Invocation Error
}, onTotalLog: { text in
// Invocation Log
}, onCompleted: {
// invocation completed
}, disposeBag: disposeBag)
Parameter
BSA.APICaller.checkUserKeyAvailable(userKey: String,
onUserKeyAvailable: @escaping () -> (),
onUserKeyNotAvailable: @escaping () -> (),
onFailed: @escaping OnFailed,
onError: @escaping OnError,
onTotalLog: @escaping OnTotalLog? = nil,
onCompleted: @escaping onCompleted? = nil,
disposeBag: DisposeBag )
Parameter | Type | Description |
---|---|---|
userKey | String | UserKey to check availability. |
onUserKeyAvailable | () -> () | Callback called if the UserKey is available. |
onUserKeyNotAvailable | () -> () | Callback called if the UserKey is unavailable. |
onFailed | OnFailed | Callback function called on API processing failure. |
onError | OnError | Callback function called on error. |
onTotalLog | OnTotalLog | Callback function to receive all logs generated during API calls. |
onCompleted | onCompleted | Called at the end after all processes are completed. |
disposeBag | DisposeBag | DisposeBag variable to manage RxSwift Disposable objects. |
vi. Local Authentication
Used to validate the UserID required during SignUp.
When called, it performs biometric and passcode authentication. For SignUp, there is no saved DomainState for biometric authentication, so checkDomainStateChanged should be set to false. Local Authentication must succeed to invoke BSA.APICAller.requestSignUp. The callback called with onResult runs on a background thread, so UI operations should be done on the main thread.
API : BSA.LocalAuth.startSimpleAuthExample
BSA.LocalAuth.startSimpleAuth(localAuthType: .BIOMETRIC,
reason: "Authentication is required to verify your identity",
checkDomainStateChanged: false,
usePasscodeWhenFailed: false,
onSuccess: {
// onSuccess operates on a background thread, so UI-related tasks should be performed on the main thread.
DispatchQueue.main.async {
// Local Authentication Successful
}
}, onError: { errorCode in
// onError operates on a background thread, so UI-related tasks should be performed on the main thread.
DispatchQueue.main.async {
// Local Authentication Failed
switch errorCode {
case .DOMAIN_STATE_CHANGED:
// Biometric authentication info has been changed
case .BIOMETRIC_NOT_AVILABLE
case .BIOMETRIC_NOT_SUPPORT_HARDWARE
case .BIOMETRIC_LOCK_OUT:
// Biometric authentication not available
case .BIOMETRIC_NOT_ENROLLED_DEVICE:
// Biometric authentication info is not on device
case .PASSCODE_NOT_ENROLLED_DEVICE:
// Passcode not on device
case .USER_CANCEL, .USER_FALLBACK:
// User cancels authentication
case .AUTH_FAILED:
// Authentication failed
default:
// Other errors
}
}
})
Parameter
BSA.LocalAuth.startSimpleAuth(
localAuthType: BSA.Enums.LocalAuthType,
reason: String,
checkDomainStateChanged: Bool,
usePasscodeWhenFailed: Bool,
onSuccess: @escaping ()->(),
onError: @escaping (BSA.LocalAuthHelper.ErrorCode?)->())
Parameter | Type | Description |
---|---|---|
localAuthType | BSA.Enums.LocalAuthType | Local authentication type |
reason | String | Message displayed on OS during biometric authentication |
checkDomainStateChanged | Bool | Determine whether to detect biometric changes |
usePasscodeWhenFailed | Bool | Decide whether to use a passcode when biometric authentication fails |
onSuccess | ()->() | Local authentication processing result callback |
onError | (BSA.LocalAuthHelper.ErrorCode?)->() | Local authentication processing result callback |
vii. Sign Up
userData must be filled with complete data when making the call.
API : BSA.APICaller.requestSignUpExample
BSA.APICaller.requestSignUp(userData: data.userData!,
onSuccess: {
// Success SignUp
}, onFailed: { [weak self] rtCode, resultMessage in
// Invocation Failure
}, onError: { [weak self] error in
// Invocation Error
}, onTotalLog: { text in
// Invocation Log
}, onCompleted: {
// invocation completed
}, disposeBag: disposeBag)
Parameter
BSA.APICaller.requestSignUp(userData: BSA.SignUpData.UserData,
onSuccess: @escaping () -> (),
onFailed: @escaping OnFailed,
onError: @escaping OnError,
onTotalLog: @escaping OnTotalLog? = nil,
onCompleted: @escaping onCompleted? = nil,
disposeBag: DisposeBag )
Parameter | Type | Description |
---|---|---|
userData | BSA.SignUpData.UserData | Data required for SignUp. Fill all fields and make the call. |
onSuccess | () -> () | Callback called on SignUp success. |
onFailed | OnFailed | Callback function called on API processing failure. |
onError | OnError | Callback function called on error. |
onTotalLog | OnTotalLog | Callback function to receive all logs generated during API calls. |
onCompleted | onCompleted | Called at the end after all processes are completed. |
disposeBag | DisposeBag | DisposeBag variable to manage RxSwift Disposable objects. |
BSA.SignUpData.UserData
Name | Type | Description |
---|---|---|
appPackage | String | App's bundleIdentifier |
clientKey | String | Client's unique Key |
appVersion | String | App version (e.g., 1.1.1) |
token | String | FCM token value. |
String | Email address. | |
phoneNumber | String | Phone number. |
userKey | String | UserID |
name | String | User name |
authType | BSA.Enums.LocalAuthType | Local Authentication Type (NONE, BIOMETRIC, PASSCODE) |
os | BSA.Enums.OSType | os type (fixed to iOS) |
disposeToken | String | Token received upon OTP authentication success. |
agreeGccs | Bool | Agreement to BSA Terms of Use. |
agreePerson | Bool | Agreement to Privacy Policy. |
agreeDevice | Bool | Agreement to Device Information Policy. |
Information saved after SignUp
If SignUp is successful, you can retrieve information using the following functions.
- BSA.loadTOTPSecretKey
- BSA.loadDeviceID
- BSA.loadFCMToken
- BSA.loadUserKey
- BSA.loadLocalAuthType