Collecting Returns
class ViewController: UIViewController, ZaigIosOcrControllerDelegate {
// Do something if QI Tech OCR's SDK succesfully collected document picture
func zaigIosOcrController(_ ocrViewController: ZaigIosOcrController, didFinishWithResults response: ZaigIosOcrControllerResponse) {
}
// Do something if QI Tech OCR's SDK found any error when collecting document picture
func zaigIosOcrController(_ ocrViewController: ZaigIosOcrController, didFailWithError error: ZaigIosOcrControllerError) {
}
// Do something if the user canceled the picture collection on any steps
func zaigIosOcrControllerDidCancel(_ ocrViewController: ZaigIosOcrController) {
}
}
To obtain the SDK responses, you must implement the ZaigIosOcrControllerDelegate delegate in your controller, as shown in the example above.
ZaigIosOcrControllerResponse
The ZaigIosOcrControllerResponse class is used so you can receive the response from QI Tech's SDK.
In the table below you will find the detail of all properties of this class:
| name | type | description |
|---|---|---|
| OcrResponses | List of OcrResponse | Identifies |
OcrResponse Object
| name | type | description |
|---|---|---|
| OcrKey | string | Unique identifier of the image in QI Tech. You must store this identifier to send to the QI Tech API that will perform the validation (e.g.: Onboarding API) |
| DocumentTemplate | ZaigIosOcrDocumentTemplate | Enumerator that identifies which photo that OCR Key refers to. |
The possible values of the ZaigIosOcrDocumentTemplate enumerator can be:
ZaigIosOcrDocumentTemplate.CnhFull- Identifies the result of the complete CNH validation.ZaigIosOcrDocumentTemplate.CnhFront- Identifies the result of the CNH front validation.ZaigIosOcrDocumentTemplate.CnhBack- Identifies the result of the CNH back validation.ZaigIosOcrDocumentTemplate.RgFront- Identifies the result of the RG front validation.ZaigIosOcrDocumentTemplate.RgBack- Identifies the result of the RG back validation.ZaigIosOcrDocumentTemplate.NationalRegistryOfForeignersFront- Identifies the result of the National Registry of Foreigners front validation.ZaigIosOcrDocumentTemplate.NationalRegistryOfForeignersBack- Identifies the result of the National Registry of Foreigners back validation.
ZaigIosOcrControllerError
The ZaigIosOcrControllerError class is triggered in case of any error that leads to the SDK shutdown. When this occurs, QI Tech will return a subclass that will have a name corresponding to the error that led to the SDK shutdown, as shown in the table below:
| class | description |
|---|---|
| InvalidMobileToken | MobileToken sent in the settings is invalid. |
| MissingPermission | One of the permissions necessary for validation was not sufficient. |
| NetworkFailure | The user lost internet connection during validation. |
| ServerFailure | QI Tech's server returned some error response to the SDK. |
| MissingStorage | There is not enough storage space on the user's device for the image collection to be performed. |
| LowImageQuality | For some reason the quality of the collected image was not sufficient for validation to be performed. |
To map which subclass, and therefore, what the error reason is, use Swift's isKindOfClass() method.