Initial Integration
Capturing Selfies
Selfie capture sessions are created via CFASelfieController
and handled by a CFASelfieScanDelegate
. For every capture session, you must cover these steps:
Get the shared instance of
CFASelfieController
Instantiate
CFASelfieSettings
and configure desired settingsRespond to
CFASelfieScanDelegate
invocations
import UIKit
import IDMetricsSelfieCapture
class ViewController: UIViewController, CFASelfieScanDelegate {
func startCapture() {
if let selfieController = CFASelfieController.sharedInstance() as? CFASelfieController {
let settings = CFASelfieSettings()
selfieController.scanSelfie(self, selfieSettings: settings, selfieScanDelegate: self)
}
}
// MARK: - CFASelfieScanDelegate
func onFinishSelfieScan(_ selfieScanData: CFASelfieScanData!) {
print("Selfie scan result: \(selfieScanData)")
}
func onCancelSelfieScan() {
print("Selfie scan canceled")
}
func onFinishSelfieScanWithError(_ errorCode: Int32, errorMessage: String!) {
print("Error code: \(errorCode)")
print("Error message: \(errorMessage)")
}
}