Skip to main content

Communication

Upload a document and get instant results. Gain a deeper understanding of how Veryfi Lens interacts with your application.

Download on theApp StoreDownload on theGoogle Play

  1. Set your delegate:
VeryfiLens.shared().delegate = self
  1. Implement the delegate methods:
extension ViewController: VeryfiLensDelegate {

func veryfiLensClose(_ json: [String : Any]) {
let jsonData = try? JSONSerialization.data(withJSONObject: json as Any, options: .prettyPrinted)
let jsonString = String(data: jsonData!, encoding: .utf8)
print(String("veryfiLensClose: " + jsonString!)) // do something with the JSON here
}

func veryfiLensUpdate(_ json: [String : Any]) {
let jsonData = try? JSONSerialization.data(withJSONObject: json as Any, options: .prettyPrinted)
let jsonString = String(data: jsonData!, encoding: .utf8)
print(String("veryfiLensUpdate: " + jsonString!)) // do something with the JSON here
}

func veryfiLensSuccess(_ json: [String : Any]) {
let jsonData = try? JSONSerialization.data(withJSONObject: json as Any, options: .prettyPrinted)
let jsonString = String(data: jsonData!, encoding: .utf8)
print(String("veryfiLensSuccess: " + jsonString!)) // do something with the JSON here
}

func veryfiLensError(_ json: [String : Any]) {
let jsonData = try? JSONSerialization.data(withJSONObject: json as Any, options: .prettyPrinted)
let jsonString = String(data: jsonData!, encoding: .utf8)
print(String("veryfiLensError: " + jsonString!)) // do something with the error JSON here
}
}

Delegate Definitions

  • veryfiLensClose - the Veryfi Lens camera has been closed, either as a result of submitting an image for processing, or the user closed the camera without submitting an image.
{
"status": "close",
"queue_count": 1,
"framework-version": "1.4.0",
"session_scan_count": 1,
"framework-build": "1"
}

NOTE: In the object above, queue_count refers to the number of submitted documents that are currently in the processing queue. session_scan_count refers to the number of documents that were submitted in the most recent Lens camera session - if this is equal to 0 (zero) then the camera session was canceled without submitting anything.

  • veryfiLensUpdate - during the processing of a document, this delegate will be fired multiple times. One time it will contain the thumbnail path for the submitted document and one time it will contain a full-size image path. In addition, multiple instances of this delegate will be fired containing the current upload progress percentage.

Sample package created notification:

{
"status": "start",
"package_id": "edc8653e4c2b4ef1"
}

Thumbnail shared example:

{
"status": "inprogress",
"msg": "img_thumbnail_path",
"data": "/path/to/thumbnail.jpg",
"package_id": "edc8653e4c2b4ef1"
}

Full-size image shared example:

{
"status": "inprogress",
"msg": "img_original_path",
"data": "/path/to/image.jpg",
"package_id": "edc8653e4c2b4ef1",
"document_type": "receipt"
}

Stitched PDF shared example:

{
"status": "inprogress",
"msg": "img_stitched_pdf_path",
"data": "/path/to/images.pdf",
"package_id": "edc8653e4c2b4ef1"
}

Upload progress example:

{
"status": "inprogress",
"msg": "progress",
"data": 68,
"package_id": "edc8653e4c2b4ef1"
}

Package removed example:

{
"status": "removed",
"msg": "clear_package",
"package_id": "edc8653e4c2b4ef1"
}
  • veryfiLensError - if an error occurs during uploading or processing a submitted or a general exception or crash is caught in Veryfi Lens, this notification contains the error details.

Sample error data:

{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"error": "[Wombat].Reachability.noInternetConnection"
}
  • veryfiLensSuccess - this delegate fires once a document has finished processing, whether it was submitted via the camera, the gallery, or it was dictated or entered/typed manually. This delegate provides the response from the Veryfi API.

Example:

{
"status": "done",
"data": {"pdf_url":"https:\/\/cdn.veryfi.com\/w9s\/partner-receipts\/fd41feb8-77c0-4f55-b0db-b771097c7a12\/f8df92c6-0cf0-4e21-91f5-4435975acecd.pdf?Expires=1695936298&Signature=Fi34Y2ypPfVdQW8DkWAx~yLzN-dwe8~Spo9ebSvAinQZIVFie5JXwbs~TACXSsOq0-xaAstyturSPwca9uOIGjqcw0cDUHiOXhTi3SYjLcFOeUcSefFlYYK5j1i-fOWRbDCHdx~FZ~XwYwz2MGVZaowQECTn6b-br0MKtLWO9AbNy01lNN2zorU6IQasHNwdtbNX2Ka9j17U34RFsPjcIPb3mzBnDGVBp-VfCoN8rxEhKzX45KiCKn7QueUDc1PV6I60izK7tq-gefPgbtZlyDtZPmAa3~yECy-E-e8qlJEwEyi4ePCKRRAeN5o7ysadNVXycpKn1NLWLApvZ3~x3A__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ","id":74512,"account_numbers":null,"address1":"28 E 3rd Ave, Suite 201","address2":"San Mateo, California, 94401","business_name":null,"c_corp":true,"ein":null,"exempt_payee_code":null,"exemption":null,"individual":true,"llc":false,"llc_type":null,"name":"Veryfi, Inc.","other_description":null,"other":true,"partnership":false,"requester":"AcMe Corporation 1010 Elm Str,\nMountain View, CA 94043","s_corp":true,"signature_date":"2020-06-19","signature":true,"ssn":null,"trust_estate":true },
"package_id": "0873199692b34396"
}