BcmScanController

The Scan Controller (BcmScanController) is the Biocapture SDK's central Controller and the main player in the scanning process. It internally manages a camera object and a scan session.

The Scan Controller is configured using an instance of the BcmGlobalConfig and the BcmScanConfig.

Progress is reported to an object implementing the PBcmFlowDelegate interface. Please refer to the usage examples for a high-level overview of the Scan Fragment.

Caveats

Changes made to the SDK global configuration through BcmGlobalConfig are applied only when a scan session is started. Configure the SDK while no Scan Controller (BcmScanController) is active to ensure that your configuration is applied to all scan sessions.

Interface

Swift:

open class BcmScanController: ScanController {

    // MARK: - Scan view controller creation
    override public init(
        /**
         * A object enables basic configuration of SDK behavior.
         */
        globalConfig: BcmGlobalConfig = BcmGlobalConfig(),

        /**
         * An instance of IBcmSdkScanConfig, which may be changed/replaced at will prior to presenting the scan fragment
         */
        scanConfig: BcmScanConfig = BcmScanConfig(),

        /**
         *  A delegate object for scan flow events
         */
        flowDelegate: PBcmFlowDelegate? = nil
    ) {
        super.init(globalConfig: globalConfig,
                   scanConfig: scanConfig,
                   flowDelegate: flowDelegate)
    }

}

Usage

Configuring the Scan Controller

The Scan Controller maintains the Biocapture SDK's global configuration using the BcmGlobalConfig interface. The BcmGlobalConfig object can be set in the Constructor of the Controller, using the globalConfig field.

Additionally, you may change the Scan behavior by providing your own instance of scanConfig or changing values of the configuration object. For a list of configurable options, please refer to the class documentation of BcmScanConfig.

Assign a flowDelegate object to receive information about scan progress and the final result (PBcmFlowDelegate).

Swift:

let bcmGlobalConfig = BcmGlobalConfig(
            licenseKey: "<licenseKey>", ...)

let bcmScanConfig = BcmScanConfig(
            scanTerminationOption: ScanTerminationOptions.BUTTON, ...)

...

let bcmScanController = BcmScanController(globalConfig: BcmGlobalConfig(),
                                          scanConfig: bcmScanConfig,
                                          flowDelegate: self)

The settings are applied for all future scan sessions during your app's Scan Controller lifetime.

Creating a Scan Controller Instance

Once configured, you are ready to scan fingerprints by presenting BcmScanController using the UIWindow of the AppDelegate:

Swift:

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var bcmScanController: BcmScanController?
    let bcmScanConfig = BcmScanConfig(
        camera: BcmCamera(
            frameResolution: BcmCamera.CameraResolution._4K,
            isTorchInitiallyOn: true))

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        print(String(format: "BCM-SDK-App version: %@%",
                     BcmInfo.versionDetailed()))

        bcmScanController = BcmScanController.initialize(globalConfig: BcmGlobalConfig(),
                                                         scanConfig: bcmScanConfig,
                                                         flowDelegate: self)

        self.window = UIWindow(frame: UIScreen.main.bounds)
        self.window?.rootViewController = self.bcmScanController
        self.window?.makeKeyAndVisible()

        return true
    }

}

Scan Session Management

The Scan Controller by default automatically manages scan sessions, meaning it will start a scan session when presented, stop it when hidden or dismissed, and restart a new scan session after a scan completes (unless dismissed by the AppDelegate).

See Also

results matching ""

    No results matching ""