Skip to content

Installation

i. Install with Cocoapods

iOS SDK can be installed with Cocoapods and Cocoapods version must be 1.13.4 and above. If Cocoapods is already installed, move to the directory of project that will use the iOS SDK, and proceed as following. Uses RxSwift's DisposeBag for management.

swift
1. pod init - create the podfile
2. open podfile
3. add library below in the podfile

	target 'Foo' do
	  .
	  .

	# Add Alamofire and BSA_SDK. Be cautious as the version of BSA_SDK may change.
	  pod 'Alamofire'
	  pod 'BSA_SDK', '0.12.1', :source => 'https://github.com/fnsvalue-git/BSA-SDK-PodSpec.git'

	  .
	  .
	end

	# Add build settings
	post_install do |installer|
	  installer.pods_project.targets.each do |target|
	    target.build_configurations.each do |config|
	      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
	      config.build_settings[‘BUILD_LIBRARY_FOR_DISTRIBUTION’] = ‘YES’
	    end
	  end
	end

	
4. come back to the terminal and do 'pod install'

Important:

Below libraries will be automatically installed with iOS SDK.

  • CyrptoSwift
  • SwiftyJSON
  • StompClientLib
  • DeviceKit
  • SwiftOTP

If in xcworkspace file, doesn’t have BSA_SDK Pod, please follow these steps:

  1. Run pod repo update
  2. Open Pod project’s Build Settings, change BSA SDK -> iOS and Build Active Architecture Only -> No
  3. Targets project > General > add files “Pods/BSA_SDK/BSA_SDK.xcframework” , under “Frameworks, Libraries, and Embedded Content” Section
    • The added BSA_SDK.xcframework must be set to Do Not Embed.
  4. Call “BSA.testCall” to verify the SDK installation in the log

ii. Initialization

To use iOS SDK, there are things needed to be imported. Also, to initialize iOS SDK, add in the AppDelegate.swift file like below.

swift
import BSA_SDK

@main
Class AppDelegate: UIResponder, UIApplicationDelegate {

func application (_application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize the BSA_SDK
BSA_SDK.initialize(serverUrl: String, websocketUrl: String, securityKey: String, removeToken:Bool = true )
}
}

Parameter

KeyTypeDescription
serverUrlStringDefault URL for API calls
websocketUrlStringDefault WebSocket URL for node verification
securityKeyStringKey used for data generation within the SDK
removeTokenBoolDecide whether to delete the AccessToken issued during authentication when initializing the SDK. Default is true

Important:

In order to fully utilize the iOS SDK, the client application must be registered to generate the client key. Kindly reach us via Sandbox HelpDesk regarding this matter.

iii. Device Verification

API: BSA.APICaller.checkDevice

swift

BSA.APICaller.checkDevice(bundleIdentifier: "com.fnsv.sdk", 
						  clientKey: "a1hrg2xv...",
onSuccessByRegistered: { [weak self] data in

	// Registered Devices

}, onSuccessByNotRegistered: { 

	// Unregistered Devices

}, onFailed: { [weak self] rtCode, resultMessage in

	// Invocation Failure

}, onError: { [weak self] error in

	// Invocation Error

}, onTotalLog: { text in

	// Invocation Log

}, disposeBag: disposeBag)

Parameter

swift
BSA.APICaller.checkDevice(
		bundleIdentifier: String, 
		clientKey: String,
		onSuccessByRegistered: @escaping (BSA.JSONData.CheckDeviceData) -> (),
		onSuccessByNotRegistered: @escaping () -> (),
		onFailed: @escaping OnFailed, 
		onError: @escaping OnError, 
		onTotalLog: @escaping OnTotalLog,
		disposeBag: DisposeBag )
KeyTypeDescription
bundleIdentifierStringApp's bundleIdentifier
clientKeyStringClient's unique key
onSuccessByRegistered(BSA.JSONData.CheckDeviceData) -> ()Called when the device is registered. Returns CheckDeviceData.
onSuccessByNotRegistered() -> ()Called when the device is not registered.
onFailedOnFailedCallback function called on API processing failure.
onErrorOnErrorCallback function called on error.
onTotalLogOnTotalLogCallback function to receive all logs generated during API calls.
disposeBagDisposeBagDisposeBag variable to manage RxSwift Disposable objects.

Check whether the current device is registered with the server as SignUp or Register New Device.

  • If the device is registered, you can find brief User information in BSA.JSONData.CheckDeviceData, so use that information.
  • If the device is not registered, you should proceed with SignUp or Register New Device. The user's last Local Authentication Type can be determined after calling this function by using BSA.loadLocalAuthType().

BSA.JSONData.CheckDeviceData

KeyTypeDescription
userKeyStringUserID
nameStringUser Name
phoneNumStringPhone Number
emailStringEmail Address
uptDtStringModification Date