Barcode Capture Listener

Defined in framework ScanditBarcodeCapture

SDCBarcodeCaptureListener
@protocol SDCBarcodeCaptureListener <NSObject>

Added in version 6.0.0

Delegate protocol for traditional barcode capture.

- didStartObservingBarcodeCapture:
- (void)didStartObservingBarcodeCapture:(SDCBarcodeCapture *)barcodeCapture

Added in version 6.0.0

Called when the listener starts observing the barcode capture instance.

- didStopObservingBarcodeCapture:
- (void)didStopObservingBarcodeCapture:(SDCBarcodeCapture *)barcodeCapture

Added in version 6.0.0

Called when the listener stops observing the barcode capture instance.

- barcodeCapture:didScanInSession:frameData:
- (void)barcodeCapture:(SDCBarcodeCapture *)barcodeCapture
      didScanInSession:(SDCBarcodeCaptureSession *)session
             frameData:(id<SDCFrameData>)frameData

Added in version 6.0.0

Invoked whenever a code has been scanned. The newly scanned codes can be retrieved from SDCBarcodeCaptureSession.newlyRecognizedBarcodes.

This method is invoked from a recognition internal thread. To perform UI work, you must dispatch to the main thread first. After receiving this callback, you will typically want to start processing the scanned barcodes. Keep in mind however, that any further recognition is blocked until this method completes. Therefore, if you need to perform a time-consuming operation, like querying a database or opening an URL encoded in the barcode data, consider switching to another thread.

Sometimes, after receiving this callback, you may want to pause scanning or to stop scanning completely.

  • To pause scanning, but keep the camera (frame source) running, just set the barcode capture’s enabled property to NO.

captureMode.isEnabled = true

While it’s possible to only stop the camera and keep the capture mode enabled, this may lead to additional scan events being delivered, which is typically not desired. The following lines of code show how to disable the capture mode and stop the frame source as well:

// no more didScan callbacks will be invoked after this call.
captureMode.isEnabled = false
// asynchronously turn off the camera as quickly as possible.
captureMode.context?.frameSource?.switch(toDesiredState: .off, completionHandler: nil)
- barcodeCapture:didUpdateSession:frameData:
- (void)barcodeCapture:(SDCBarcodeCapture *)barcodeCapture
      didUpdateSession:(SDCBarcodeCaptureSession *)session
             frameData:(id<SDCFrameData>)frameData

Added in version 6.0.0

Invoked after a frame has been processed by barcode capture and the session has been updated. In contrast to barcodeCapture:didScanInSession:frameData:, this method is invoked, regardless whether a code was scanned or not. If codes were recognized in this frame, this method is invoked after barcodeCapture:didScanInSession:frameData:.

This method is invoked from a recognition internal thread. To perform UI work, you must dispatch to the main thread first. Further recognition is blocked until this method completes. It is thus recommended to do as little work as possible in this method.

See the documentation in barcodeCapture:didScanInSession:frameData: for information on how to properly stop recognition of barcodes.

Barcode Capture Advanced Listener

Defined in framework ScanditBarcodeCapture