Launching on iOS
Overview
The Capture Flow includes capturing receipt images, uploading the resulting images, and notifying a provided listener of flow progress. To launch, Capture Flow requires a hosting UIViewController
To launch the capture flow, use the CaptureFlow.Coordinator .
Info
Before launching the Capture Flow, please follow the Installation and Authentication , and Start SDK steps.
Basic Steps
Declare the conformance to CaptureFlowCoordinatorDelegate protocol to receive events upon capture flow completion in one of the classes (most commonly - the host view controller you selected in step 1).
- the
coordinatorDidFinishCapture(_:result:)
event will be triggered when user captures one or more documents. - the
coordinatorDidCancelCapture
event will be triggered when the capture flow completes without any images captured (e.g. user cancelled the capture, or an error occurred). - the optional
coordinatorWillBeginCapture
event will be triggered when Capture UI starts.
- the
Define a CaptureFlow.Coordinator property to the selected host view controller. This property will be used to retain an instance of the coordinator while the capture flow is displayed.
Create an instance of
CaptureFlow.Coordinator
by passing your hostUIViewController
as an argument.Set the delegate for the
CaptureFlow.Coordinator
to a class which conforms toCaptureFlowCoordinatorDelegate
protocol.Call the
start()
function of the coordinator instance to launch Capture Flow.Make sure to set your coordinator instance to
nil
when eithercoordinatorDidFinishCapture
orcoordinatorDidCancelCapture
event was received.
Example
import Sensibill
class MyViewController: UIViewController {
// MARK: - Private Properties
private var captureFlowCoordinator: CaptureFlow.Coordinator?
// MARK: - Private Methods
private func startCaptureFlow() {
let coordinator = CaptureFlow.Coordinator(host: self)
coordinator.delegate = self
coordinator.start()
self.captureFlowCoordinator = coordinator
}
}
// MARK: - CaptureFlowCoordinatorDelegate
extension MyViewController: CaptureFlowCoordinatorDelegate {
// A user captured one or more documents, and they were submitted to Sensibill API for processing.
func coordinatorDidFinishCapture(_ coordinator: CaptureFlowCoordinator, result: CaptureFlowCoordinator.DidFinishCaptureResult) {
captureFlowCoordinator = nil
}
// A user taps on cancel button on the capture screen, or an error occurred
func coordinatorDidCancelCapture(_ coordinator: CaptureFlowCoordinator) {
self.captureFlowCoordinator = nil
}
// (Optional) A Capture UI had started
func coordinatorWillBeginCapture(_ coordinator: CaptureFlowCoordinator) {
// capture flow about to be started.
}
}
Capture Flow Customization
Branding
You can also customize Capture appearance (colors, fonts), and Tips. See Branding for more information.
Capture Feature Flags
You can also provide Capture Feature Flags to enable/disable or configure certain aspects of Capture behavior. See Capture Feature Flags for more information.