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.
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:
- Run pod repo update
- Open Pod project’s Build Settings, change BSA SDK -> iOS and Build Active Architecture Only -> No
- 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 toDo Not Embed
.
- The added
- 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.
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
Key | Type | Description |
---|---|---|
serverUrl | String | Default URL for API calls |
websocketUrl | String | Default WebSocket URL for node verification |
securityKey | String | Key used for data generation within the SDK |
removeToken | Bool | Decide 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
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
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 )
Key | Type | Description |
---|---|---|
bundleIdentifier | String | App's bundleIdentifier |
clientKey | String | Client's unique key |
onSuccessByRegistered | (BSA.JSONData.CheckDeviceData) -> () | Called when the device is registered. Returns CheckDeviceData. |
onSuccessByNotRegistered | () -> () | Called when the device is not registered. |
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. |
disposeBag | DisposeBag | DisposeBag 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
Key | Type | Description |
---|---|---|
userKey | String | UserID |
name | String | User Name |
phoneNum | String | Phone Number |
String | Email Address | |
uptDt | String | Modification Date |