PBcmFlowDelegate
The scan flow delegate receives messages about scan progress and results by BcmScanController. It provides your application with the scan result or error, including environment-related errors such as license or calibration problems.
You may provide your own scan flow by implementing the following interface:
Interface
Swift:
/**
* Scan flow delegate - callback from the SDK
* When running code - which have to run on the main thread - you've to dispatch the code block
* to the main thread
* @author Manuel Schmitzberger <ms@ms-sw.at>
*/
import Foundation
public enum ScanError {
/**
* There is a problem with the given license key.
* Please also check the network connection - a network connection is mandatory.
*/
case LICENSE_PROBLEM
/**
* No pre-calibration configuration for the device was found.
*/
case DEVICE_NOT_CALIBRATED
/**
* An internal error occurred, please inspect the logs for details.
*/
case UNKNOWN
/**
* The camera cannot be used due to an error.
*/
case CAMERA_PROBLEM
/**
* The scan was interrupted
*/
case SCAN_INTERRUPTION
/**
Presentation attack detected during liveness check.
The error message contains "G" for glare or "P" for parallax.
*/
case PAD_DETECTED
}
public protocol PBcmFlowDelegate: class {
/**
* Something went terribly wrong (as indicated by errorCode) and things are now broken.
* Notify your user.
*/
func bcmUnrecoverableError(
errorCode: ScanError,
errorMessage: String
)
/**
* A scan has completed.
* Inspect the BcmFingerImageDTO structure to check the recorded fingerprints.
* The scan termination can be configured via the `BcmSdkConfig`
*/
func bcmFingerImagesResult(
fingerImages: Set<BcmFingerImage>
)
/**
* Finger selection dialog callback.
* The callback contains a set of all finger selected in the Finger selection dialog.
*
* Optional
*/
func bcmFingerSelected(
excludedFingers: Set<BcmFingerHand>,
selectedFingers: Set<BcmFingerHand>
)
/**
*
* Setup has completed and fingers may now be scanned.
*
* Optional
*/
func bcmReadyToScan()
/**
* Hand recognized.
* Inspect the hand structure for the object details.
* The callback includes a count of the founded fingers.
* The distance is a value in the rage (0 - 1.0) (far - close)
* The callback will continuously called, during the scan.
*
* Optional
*/
func bcmHandDetected(
hand: Hand,
fingerCount: Int,
distance: Float
)
/**
* Fingers recognized on the given preview position with a given evaluation score.
* Inspect the AssignedBoundingBox structure for the object details.
* The callback will continuously called, during the scan.
*
* Optional
*/
func bcmBoundingBoxesAssigned(
assignedBoundingboxes: Set<AssignedBoundingBox>
)
/**
* Internal finger cache was updated, because fingers with a better score was detected.
* Inspect the BcmFingerImageLiveScoreDTO structure to check live score.
* The callback will continuously called, during the scan.
*
* Optional
*/
func bcmFingerImagesCachedLiveScore(
fingerImageLiveScores: Set<BcmFingerImageLiveScore>
)
}
public extension PBcmFlowDelegate {
func bcmFingerSelected(
excludedFingers: Set<BcmFingerHand>,
selectedFingers: Set<BcmFingerHand>
) {
}
func bcmReadyToScan() {
}
func bcmBoundingBoxesAssigned(
assignedBoundingboxes: Set<AssignedBoundingBox>
) {
}
func bcmFingerImagesCachedLiveScore(
fingerImageLiveScores: Set<BcmFingerImageLiveScore>
) {
}
}
Usage
Implement at least PBcmFlowDelegate.unrecoverableError()
and PBcmFlowDelegate.fingerImagesResult() for receiving scan results.
Using the PBcmFlowDelegate.fingerImagesCachedLiveScore() it is possible to implement your own scan
termination logic. Please refer to Custom Scan Termination
for an example implementation.
The BCM SDK callbacks can be implemented in the in the AppDelegate as follows
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
...
}
// MARK: - Bcm SDK callbacks
extension AppDelegate: PBcmFlowDelegate {
func bcmUnrecoverableError(
errorCode: ScanError,
errorMessage: String
) {
}
func bcmFingerImagesResult(
fingerImages: Set<BcmFingerImage>
) {
}
/**
* Optional
*/
func bcmFingerSelected(
excludedFingers: Set<BcmFingerHand>,
selectedFingers: Set<BcmFingerHand>
) {
}
func bcmReadyToScan() {
}
func bcmHandDetected(
hand: Hand,
fingerCount: Int,
distance: Float
) {
}
func bcmBoundingBoxesAssigned(
assignedBoundingboxes: Set<AssignedBoundingBox>
) {
}
func bcmFingerImagesCachedLiveScore(
fingerImageLiveScores: Set<BcmFingerImageLiveScore>
) {
}
}