Usage
- iOS
- Android
- Capacitor
- React Native
- Flutter
- .NET
1. Launch the Lens camera:
VeryfiLens.shared().showCamera(in: self)
2. Optionally, instead of launching the Lens camera experience, you may perform one of the following:
- Launch the Gallery screen to submit images from the Photo Gallery:
VeryfiLens.shared().showGallery(in: self)
- Launch the Files Browser screen to submit documents:
VeryfiLens.shared().showDocumentBrowser(in: self)
Note: When uploading a PDF if the file has password, Lens will return an error on onVeryfiLensError
with msg
-> invalid_pdf_file
, and it's up to you validate the error so that users know why their file could not be processed
- Retry uploading specific package:
VeryfiLens.shared().utils.retryPackage(with: packageId)
- Retry uploading all packages currently in queue
VeryfiLens.shared().utils.retryAllPackages()
- Remove specific package from the queue
VeryfiLens.shared().utils.discardPackage(with: packageId)
- Remove all packages from the queue
VeryfiLens.shared().utils.discardAllPackages()
- Share OCR feedback for last scan
VeryfiLens.shared().shareOCRFeedback()
1. Manage the Lens experience:
- Enable buffer processing which starts detection of documents
VeryfiLensHeadless.shared().startProcessingBuffer()
- Process a frame buffer to see if there's any document
VeryfiLensHeadless.shared().processWithBlock(buffer: frame) { rectangles, buffer in
// Call adjustedRectangles like this to change corner values that you can use on your camera view to draw
let convertedRectangles = VeryfiLensHeadless.shared().adjustedRectangles(
rectangles,
for: buffer,
videoPreviewLayer: cameraView.previewLayer // set your camera previwLayer
)
// Draw some borders with the rectangles object
}
- Disable buffer processing which stops/pauses detection of documents
VeryfiLensHeadless.shared().stopProcessingBuffer()
- Returns adjusted corners of detected documents in camera (intended for those who want to draw over those coordinates)
VeryfiLensHeadless.shared().adjustedRectangles(
_ rectangles: [RectangleFeature],
for buffer: CMSampleBuffer,
videoPreviewLayer: AVCaptureVideoPreviewLayer) -> [RectangleFeature]
- Reset lens state
VeryfiLensHeadless.shared().reset()
- Close lens (Call this whenever you want to reset the autocapture process after document detection)
VeryfiLensHeadless.shared().close()
2. Optionally, you may use the following at your convenience:
- Crop image (this method will return an empty [UIImage] array if no suitable corners where found to crop aka. no document detected)
VeryfiLensHeadless.shared().crop(image: rotatedImage) { [weak self] croppedImages in
// Use the croppedImages UIImage array
}
- Rotate image
VeryfiLensHeadless.shared().rotate(image: UIImage) -> UIImage
- Upload images
VeryfiLensHeadless.shared().upload(images: [UIImage])
- Uploads a document without UI
VeryfiLensHeadless.shared().upload(url: URL)
- Update lens settings
VeryfiLensHeadless.shared().updateSettings(_ settings: VeryfiLensHeadlessReceipts.VeryfiLensHeadlessSettings)
3. For all of the above features, your app will need to communicate with Lens to handle user actions, various status changes and extraction results from Veryfi. See the Communicating with Lens section below for details
Requested permissions
Permission | Description | Condition |
NSCameraUsageDescription | Required to be able to access the device's camera | If permissions are denied, Lens will display an alert explaining the reasons, inviting to enable them |
NSLocationWhenInUseUsageDescription | Allows an app to access location for data extraction and metadata improvements | Requested only if locationServicesIsOn is set to true |
NSPhotoLibraryUsageDescription | Allows an application to read from Photos gallery content | Requested if any of the following settings are true: • galleryIsOn • backupDocsToGallery |
NSPhotoLibraryAddUsageDescription | Allows an application to save images to Photos gallery | Requested if any of the following settings are true: • galleryIsOn • backupDocsToGallery |
1. Launch the Lens camera:
VeryfiLens.showCamera()
Note: If there is no camera available (like some Chromebooks), Lens will return an error on onVeryfiLensError
with error
-> camera_unavailable
.
2. Optionally, instead of launching the Lens camera experience, you may perform one of the following:
- Retry uploading specific package:
VeryfiLens.retryUpload(packageId: String)
- Retry uploading all packages currently in queue
VeryfiLens.retryAll()
- Remove specific package from the queue
VeryfiLens.discardUpload(packageId: String)
- Remove all packages from the queue
VeryfiLens.discardAll()
- Share OCR feedback for last scan
VeryfiLens.shareOCRFeedback()
- Close the Lens camera
VeryfiLens.closeCamera()
- Upload path of the images
VeryfiLens.uploadImages(paths: Array<String>?, isSameTransaction: Boolean = true)
- Retrieve packages in queue
VeryfiLens.packagesInQueue()
3. For all of the above features, with the exception of showEmail(), your app will need to communicate with Lens to handle user actions, various status changes and extraction results from Veryfi. See the Communicating with Lens section below for details
Requested permissions
Permission | Description | Condition |
android.permission.CAMERA | Required to be able to access the camera device | If there is no camera available (like some Chromebooks), Lens will return an error on `onVeryfiLensError` with `error` -> `camera_unavailable` |
android.permission.INTERNET | Allows applications to open network sockets | |
android.permission.ACCESS_COARSE_LOCATION | Allows an app to access approximate location | Requested only if locationServicesIsOn is set to true |
android.permission.ACCESS_FINE_LOCATION | Allows an app to access precise location | Requested only if locationServicesIsOn is set to true |
android.permission.ACCESS_NETWORK_STATE | Allows applications to access information about networks | |
android.permission.READ_EXTERNAL_STORAGE | Allows an application to read from external storage | Requested if any of the following settings are true: • galleryIsOn • browseIsOn • backupDocsToGallery |
android.permission.WRITE_EXTERNAL_STORAGE | Allows an application to write to external storage | Requested if any of the following settings are true: • galleryIsOn • browseIsOn • backupDocsToGallery |
android.permission.POST_NOTIFICATIONS | Allows an app to post notifications | |
android.permission.FOREGROUND_SERVICE | Allows a regular application to use Service.startForeground | |
android.permission.FOREGROUND_SERVICE_DATA_SYNC | Allows a regular application to use Service.startForeground with the type "dataSync" | |
android.permission.FLASHLIGHT | Allows the app to control the flashlight |
1. Launch the Lens camera:
VeryfiLensCapacitor.showCamera()
Note: If there is no camera available (like some Chromebooks), Lens will return an error on onVeryfiLensError
with error
-> camera_unavailable
(Android Only).
2. Optionally, instead of launching the Lens camera experience, you may perform one of the following:
- Retry uploading specific package:
VeryfiLensCapacitor.retryPackage(options: { packageID: String, metadata: Object, imageSourceTag: String })
- Retry uploading all packages currently in queue
VeryfiLensCapacitor.retryAllPackages()
- Remove specific package from the queue
VeryfiLensCapacitor.discardPackage(options: { packageID: String })
- Remove all packages from the queue
VeryfiLensCapacitor.discardAll()
- Share OCR feedback for last scan
VeryfiLensCapacitor.shareOCRFeedback()
This function call launches the Veryfi Lens camera experience to allow users to capture and submit documents.
VeryfiLens.showCamera();
Note: If there is no camera available (like some Chromebooks), Lens will return an error on onVeryfiLensError
with error
-> camera_unavailable
(Android Only).
If you want to show the camera right after configuring Lens you need to use the following logic to wait for the configure process to finish
VeryfiLens.configureWithCredentials(
veryfiLensCredentials,
veryfiLensSettings,
() => {
VeryfiLens.showCamera();
},
);
You can also launch experiences like showGallery and showDocumentBrowser after configuring Lens:
To show Gallery:
VeryfiLens.showGallery();
To show Document browser:
VeryfiLens.showDocumentBrowser();
Note: When uploading a PDF if the file has password, Lens will return an error on onVeryfiLensError
with msg
-> invalid_pdf_file
, and it's up to you validate the error so that users know why their file could not be processed
- Share OCR feedback for last scan
VeryfiLens.shareOCRFeedback()
1. Launch the Lens camera:
Veryfi.showCamera()
Note: If there is no camera available (like some Chromebooks), Lens will return an error on onVeryfiLensError
with error
-> camera_unavailable
(Android Only).
2. Optionally, instead of launching the Lens camera experience, you may perform one of the following:
- Retry uploading specific package:
Veryfi.retryPackage(String packageID, Map<String, Object> metadata, String imageSourceTag)
- Retry uploading all packages currently in queue
Veryfi.retryAllPackages()
- Remove specific package from the queue
Veryfi.discardPackage(String packageID)
- Remove all packages from the queue
Veryfi.discardAll()
- Share OCR feedback for last scan
Veryfi.shareOCRFeedback()
1. After configuring Lens with your credentials assign your event handler in Veryfi Lens:
- iOS: Create a strong property reference (To avoid issues like veryfi delegate events not triggering):
VeryfiLensDelegateListener _veryfiLensDelegate;
Then instanciate it and assign it:
_veryfiLensDelegate = new VeryfiLensDelegateListener(this);
VeryfiLens.Shared.Delegate = _veryfiLensDelegate;
- Android:
VeryfiLens.SetDelegate(new VeryfiLensDelegateListener());
2. Launch the Lens camera:
- iOS:
VeryfiLens.Shared.ShowCameraIn(this);
We recommend calling ConfigureWithCredentials and defining VeryfiLensDelegate in the ViewDidLoad method and calling the ShowCameraInViewController on a user initiated action so Lens has time to set up.
- Android:
VeryfiLens.ShowCamera();
You'll still need to configure the communication steps to start receiving events from Lens. So please refer to that section.
Note: If there is no camera available (like some Chromebooks), Lens will return an error on onVeryfiLensError
with error
-> camera_unavailable
(Android Only).