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
  use_frameworks!

  source 'https://github.com/CocoaPods/Specs.git'
  source '[email protected]:berbix/berbix-ios-spec.git'

  pod 'Berbix', '3.0.4'
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
    }

}

BerbixError Values

The following outlines the types of errors that could be returned in func failed(error: BerbixError). Some errors are non-recoverable and some may allow retrying the Berbix flow.

.userExitError:
The user has canceled and quit the Berbix verification. This error can be retried and the user can either restart or resume their verification.

.cameraAccessError:
The user has denied camera permissions. Suggest to the user that they need to enable camera permissions in settings to be able to complete a Berbix verification.
NOTE: In new templates with a 2.0+ SDK, this error will not occur and the Verify flow will handle permission failure and fallback to file uploads.

.apiError:
The Berbix flow failed due to an internal error. This is most likely due to an issue on the Berbix backend. This error should be retry-able, and should be reported to Berbix support if it happens continuously.

.invalidState:
The Berbix flow failed due to an unknown error. This is likely similar to the apiError and can be retried.

Demo App Source Code

A demo app source code is available here and can help with integration or environment setup.

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.

© Berbix Inc. All rights reserved.