Install via CocoaPods
In your Podfile
, ensure the berbix-ios-spec
Cocoapod spec repository is added to your sources and then add Berbix
as one of your target dependencies.
target 'YourProject' do
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/berbix/berbix-ios-spec.git'
pod 'Berbix', '1.0.7'
end
In addition to importing the Cocoapod dependency, you will also need to set the Privacy - Camera Usage Description
in your Info.plist
to enable camera access.
Usage
To initialize the Berbix Verify flow, refer to the code sample below and include your client_token
in place of client_token_for_session
. Please see our Integration Guide for more details on initializing the Berbix Verify flow and integrating Berbix APIs.
class ViewController : UIViewController, BerbixSDKDelegate {
// This is hooked up to a button which starts the flow
@IBAction func buttonPressed(_ sender: UIButton) {
let berbixSDK = BerbixSDK()
let config = BerbixConfigurationBuilder()
.withClientToken("client_token_for_session")
.build()
berbixSDK.startFlow(self, delegate: self, config: config)
}
func completed() {
// Send request to server to fetch verification status
}
func failed(error: BerbixError) {
// Something went wrong in the execution of the flow
}
}
Reference
BerbixSDK Methods
constructor()
Constructs a Berbix SDK client. This can be used subsequently to invoke the Berbix flow within your app.
startFlow(_ vc: UIViewController, delegate: BerbixSDKDelegate, config: BerbixConfiguration)
Starts the Berbix flow and immediately takes control of the user interface. This is the most basic invocation of the flow. Upon completion of the flow, the user interface control will be returned to the app and the onComplete
adapter method will be called. Upon any irrecoverable error, the onError
adapter method will be called.
createSession(delegate: BerbixSDKDelegate, config: BerbixConfiguration, ready: @escaping () -> Void) -> BerbixSessionHandle
Creates a Berbix session but does not immediately take control of the user interface. When the session is created, ready
will be run. At that point, the user interface can be rendered immediately by calling the associated display
method. Returns a session handle that can be used to invoke the display
method.
display(_ vc: UIViewController, handle: BerbixSessionHandle)
Takes immediate control of the user interface and begins the Berbix flow. This must be called in conjunction with createSession
after the associated ready
callback runs.
BerbixSDKConfigurationBuilder Methods
constructor()
Creates a new options builder with the default initial state.
withClientToken(_ clientToken: String) -> BerbixConfigurationBuilder
Sets the client token for the session. This value is fetched from the Berbix API upon creation of a transaction.
Updated 7 months ago