Comment on page
Document
func scanDocument(
on viewController: UIViewController,
for document: Document,
cutOutType: CutOutType = .DEFAULT,
hasBackSide: HasBackSide = .DEFAULT,
doneLaunching: SybrinIdentity.doneLaunchingType? = nil,
success: SybrinIdentity.documentSuccessCallbackType? = nil,
failure: SybrinIdentity.failureCallbackType? = nil,
cancel: SybrinIdentity.cancelCallbackType? = nil
)
Handling the
doneLaunching
, success
, failure
or cancel
callbacks are optional but recommended.To find out if we support a document, check out Supported Documents!
To request support for a document, contact us!
Type | Description |
UIViewController | The controller you would like to present on. |
The document you would like to scan for. | |
| |
|
The
doneLaunching
callback will be executed after the view controller has successfully launched, or if the view controller failed to launch.Type | Description |
Bool | true if the view controller presented successfully; otherwise, false . |
String? | If an error occurs, a message describing the error; otherwise, nil . |
doneLaunching: { (didLaunch, message) in
if didLaunch {
print("Launched successfully!")
} else if let message = message {
print("Failed to launch because \(message)")
}
}
The
success
callback will be executed after scanning has finished and the view controller has been dismissed.Type | Description |
An object containing the results of the scanned document. |
As explained in Features, the
success
callback will always return the country specific model but in its parent class form (DocumentModel). However, this can be casted to the country specific model to access that country model's specific properties.This is not required, but is recommended if you would like to access the country model's specific properties.
Let's say that you provide the
scanDocument
function with the .SouthAfricaIDCard
parameter. The result will be of type SouthAfricaIDCardModel, but is returned in its parent form DocumentModel. To access all the data specific to SouthAfricaIDCardModel you will need to cast the DocumentModel to that type.success: { (model) in
if let southAfricaIDCard = model as? SouthAfricaIDCardModel {
print("This is a south african id card model! \(southAfricaIDCard.rsaCode)")
}
}
The
failure
callback will be executed after scanning has failed and the view controller has been dismissed.Type | Description |
String? | A message describing the error. |
failure: { (message) in
print("Scan document failed because \(message)")
}
The
cancel
callback will be executed after the user has dismissed the view controller and before scanning could finish.None
cancel: {
print("Scan document canceled")
}
SybrinIdentity.shared.scanDocument(on: self, for: .SouthAfricaIDCard)
{ (didLaunch, message) in
if didLaunch {
print("Launched successfully!")
} else if let message = message {
print("Failed to launch because \(message)")
}
} success: { (model) in
if let model = model as? SouthAfricaIDCardModel {
print("Scan document success: \(model.rsaCode ?? "")")
}
} failure: { (message) in
print("Scan document failed because \(message)")
} cancel: {
print("Scan document canceled")
}
Last modified 5mo ago