Skip to content

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

swift
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

swift
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 )
ParameterTypeDescription
verifyDataStringData for duplicate checking (email, phoneNumber).
verifyTypeBSA.Enums.VerifyTypeDuplicate check type (Email, PhoneNumber).
onNotDuplicateUser() -> ()Callback function called when data is not duplicate.
onDuplicateUser() -> ()Callback function called when data is duplicate.
onFailedOnFailedCallback function called on API processing failure.
onErrorOnErrorCallback function called on error.
onTotalLogOnTotalLogCallback function to receive all logs generated during API calls.
onCompletedonCompletedCalled at the end after all processes are completed.
disposeBagDisposeBagDisposeBag 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

swift
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

swift
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 )
ParameterTypeDescription
sendTypeBSA.APICaller.OTPSendTypePlatform to receive OTP number (Email, SMS)
sendTargetStringAddress for OTP number type
bundleIdentifierStringApp's bundleIdentifier
onSuccess() -> ()Callback called on success.
onFailedOnFailedCallback function called on API processing failure.
onErrorOnErrorCallback function called on error.
onTotalLogOnTotalLogCallback function to receive all logs generated during API calls.
onCompletedonCompletedCalled at the end after all processes are completed.
disposeBagDisposeBagDisposeBag 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

swift
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

swift
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 )
ParameterTypeDescription
sendTypeBSA.APICaller.OTPSendTypePlatform to receive OTP number (Email, SMS)
sendTargetStringAddress for OTP number type
otpNumberStringReceived OTP number.
clientKeyStringClient'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.
onFailedOnFailedCallback function called on API processing failure.
onErrorOnErrorCallback function called on error.
onTotalLogOnTotalLogCallback function to receive all logs generated during API calls.
onCompletedonCompletedCalled at the end after all processes are completed.
disposeBagDisposeBagDisposeBag variable to manage RxSwift Disposable objects.

iv. Check Available ID

Used to validate the UserID required during SignUp.

API : BSA.APICaller.checkUserKeyAvailableExample

swift
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

swift
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 )
ParameterTypeDescription
userKeyStringUserKey to check availability.
onUserKeyAvailable() -> ()Callback called if the UserKey is available.
onUserKeyNotAvailable() -> ()Callback called if the UserKey is unavailable.
onFailedOnFailedCallback function called on API processing failure.
onErrorOnErrorCallback function called on error.
onTotalLogOnTotalLogCallback function to receive all logs generated during API calls.
onCompletedonCompletedCalled at the end after all processes are completed.
disposeBagDisposeBagDisposeBag 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

swift
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

swift
BSA.LocalAuth.startSimpleAuth(
						localAuthType: BSA.Enums.LocalAuthType, 
						reason: String,
						checkDomainStateChanged: Bool, 
						usePasscodeWhenFailed: Bool, 
						onSuccess: @escaping ()->(), 
						onError: @escaping (BSA.LocalAuthHelper.ErrorCode?)->())
ParameterTypeDescription
localAuthTypeBSA.Enums.LocalAuthTypeLocal authentication type
reasonStringMessage displayed on OS during biometric authentication
checkDomainStateChangedBoolDetermine whether to detect biometric changes
usePasscodeWhenFailedBoolDecide 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

swift
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

swift
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 )
ParameterTypeDescription
userDataBSA.SignUpData.UserDataData required for SignUp. Fill all fields and make the call.
onSuccess() -> ()Callback called on SignUp success.
onFailedOnFailedCallback function called on API processing failure.
onErrorOnErrorCallback function called on error.
onTotalLogOnTotalLogCallback function to receive all logs generated during API calls.
onCompletedonCompletedCalled at the end after all processes are completed.
disposeBagDisposeBagDisposeBag variable to manage RxSwift Disposable objects.

BSA.SignUpData.UserData

NameTypeDescription
appPackageStringApp's bundleIdentifier
clientKeyStringClient's unique Key
appVersionStringApp version (e.g., 1.1.1)
tokenStringFCM token value.
emailStringEmail address.
phoneNumberStringPhone number.
userKeyStringUserID
nameStringUser name
authTypeBSA.Enums.LocalAuthTypeLocal Authentication Type (NONE, BIOMETRIC, PASSCODE)
osBSA.Enums.OSTypeos type (fixed to iOS)
disposeTokenStringToken received upon OTP authentication success.
agreeGccsBoolAgreement to BSA Terms of Use.
agreePersonBoolAgreement to Privacy Policy.
agreeDeviceBoolAgreement 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