using_sdk
Starting the SDK
import ZaigIosFaceRecognition
class ViewController: UIViewController, ZaigIosFaceRecognitionControllerDelegate {
var zaigFaceRecognitionConfiguration : ZaigIosFaceRecognitionConfiguration?
override func viewDidLoad() {
super.viewDidLoad()
self.setupFaceRecognition()
}
func setupFaceRecognition() -> Void {
// The environment can be 'Sandbox' or 'Production'
let environment = ZaigIosFaceRecognitionEnvironment.Sandbox
// MobileToken is the key sent to you by QI Tech. Each environment requires a different MobileToken.
let mobileToken = "YOUR_MOBILE_TOKEN_SENT_BY_QITECH"
self.faceRecognitionConfig = ZaigIosFaceRecognitionConfiguration(environment: environment,
mobileToken: mobileToken,
sessionId: "UNIQUE_SESSION_ID",
backgroundColor: "#000000",
fontColor: "#FFFFFF",
fontFamily: .open_sans,
showIntroductionScreens: true,
activeFaceLiveness: true,
audioConfiguration: AudioConfiguration.Enable,
logLevel: .debug
)
}
// Event where you intend to call QI Tech FaceRecognition View Controller - on this example, when the user press 'next' button
@IBAction func pressNext(_ sender: Any) {
let zaigFaceRecognitionController = ZaigIosFaceRecognitionController(faceRecognitionConfiguration: self.faceRecognitionConfig)
zaigFaceRecognitionViewController.delegate = self
let zaigFaceRecognitionViewController = zaigFaceRecognitionController.getViewController()
present(zaigFaceRecognitionViewController, animated: true, completion: nil)
}
// Do something if QI Tech FaceRecognition's SDK successfully collected document picture
func zaigIosFaceRecognitionController(_ faceRecognitionViewController: ZaigIosFaceRecognitionController, didFinishWithResults results: ZaigIosFaceRecognitionControllerResponse) {
}
// Do something if QI Tech FaceRecognition's SDK found any error when collecting document picture
func zaigIosFaceRecognitionController(_ faceRecognitionViewController: ZaigIosFaceRecognitionController, didFailWithError error: ZaigIosFaceRecognitionControllerError) {
}
// Do something if the user canceled the picture collection on any steps
func zaigIosFaceRecognitionControllerDidCancel(_ faceRecognitionViewController: ZaigIosFaceRecognitionController) {
}
}
To incorporate the SDK into your application, you must configure your custom capture application through the ZaigIosFaceRecognitionConfiguration class and then instantiate the ViewController ZaigIosFaceRecognitionController passing the custom configurations as an argument.
To start the face analysis process, simply call the present function to call the QI Tech ViewController that will perform the selfie capture.
It is important to implement the Delegate responsible for receiving returns in case of success, error or if the user interrupts the journey at any stage of validation.
On the side we have a complete example of the implementation.
Mobile Token
We use a Mobile Token to allow authenticated access from your application to our API. It has probably already been sent to you by email. If you have not yet received your token, send an email to suporte.caas@qitech.com.br.
Our API expects to receive the Mobile Token in all requests to our server from the SDK, therefore, it must be included as a configuration parameter through the method mentioned above.
You must replace"YOUR_MOBILE_TOKEN_SENT_BY_QITECH" with the Mobile Token received from support.