Skip to main content
Version: 7.0.1

Get Started

In this guide you will learn step-by-step how to add MatrixScan Find to your application. Implementing MatrixScan Find involves two primary elements:

  • Barcode Find: The data capture mode that is used for search and find functionality.
  • A Barcode Find View: The pre-built UI elements used to highlight found items.
note

MatrixScan Count is implemented via SDCBarcodeFind.

The general steps are:

  • Creating a new Data Capture Context instance
  • Configuring the Barcode Find Mode
  • Setup the Barcode Find View
  • Registering the Listener to notify about found items

Prerequisites

Before starting with adding a capture mode, make sure that you have a valid Scandit Data Capture SDK license key and that you added the necessary dependencies. If you have not done that yet, check out this guide.

note

You can retrieve your Scandit Data Capture SDK license key by signing in to your account Dashboard.

Create a Data Capture Context

The first step to add capture capabilities to your application is to create a new Data Capture Context. The context expects a valid Scandit Data Capture SDK license key during construction.

self.context = DataCaptureContext(licenseKey: "-- ENTER YOUR SCANDIT LICENSE KEY HERE --")

Configure the Barcode Count Mode

The main entry point for the Barcode Find Mode is the SDCBarcodeFind object. You can configure the supported Symbologies through its SDCBarcodeFindSettings, and set up the list of items that you want MatrixScan Find to highlight.

Here we configure it for tracking EAN13 codes, but you should change this to the correct symbologies for your use case.

let settings = BarcodeFindSettings()
settings.set(symbology: .ean13UPCA, enabled: true)

Next, create the list of items that will be actively searched for. We will also attach some optional information to the first item that can be used by the BarcodeFindView to display extra information:

var items = Set<BarcodeFindItem>()
items.insert(BarcodeFindItem(
searchOptions: BarcodeFindItemSearchOptions(barcodeData: "9783598215438"),
content: BarcodeFindItemContent(
info: "Mini Screwdriver Set",
additionalInfo: "(6-Piece)",
image: nil)
))
items.insert(BarcodeFindItem(
searchOptions: BarcodeFindItemSearchOptions(barcodeData: "9783598215414"),
content: nil // Content information is optional, used for display only
))

Finally, create a SDCBarcodeFind instance with the Data Capture Context and the settings initialized in the previous step:

let barcodeFind = BarcodeFind(context: context, settings: settings)
mode.setItemsList(items)

Setup the BarcodeFindView

MatrixScan Find’s built-in AR user interface includes buttons and overlays that guide the user through the searching process. By adding a SDCBarcodeFindView, the scanning interface is added automatically to your application.

The BarcodeFindView appearance can be customized through SDCBarcodeFindViewSettings to match your application’s look and feel. For example, you can change the color of the dots that are overlaid on top of the items that are found and enable sound and haptic alerts.

let viewSettings = BarcodeFindViewSettings()
viewSettings.inListItemColor = .green
viewSettings.notInListItemColor = .red
viewSettings.soundEnabled = true
viewSettings.hapticEnabled = true

Next, create a SDCBarcodeFindView instance with the Data Capture Context and the settings initialized in the previous step. he BarcodeFindView is automatically added to the provided parent view.

let barcodeFindView = BarcodeFindView(parentView: view, context: context, barcodeFind: mode, settings: viewSettings)

Last, connect the BarcodeFindView to the iOS view controller lifecycle.

note

Be sure to call BarcodeFindView.prepareSearching() on your UIViewController’s viewWillAppear method to ensure optimal start up time.

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
barcodeFindView.prepareSearching()
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
barcodeFindView.stopSearching()
}

Register the Listener

The BarcodeFindView displays a Finish button next to its shutter button button.

Here we register a SDCBarcodeFindViewUIDelegate to be notified what items have been found once the finish button is pressed, and then navigate back to the previous screen to finish the find session.

barcodeFindView.uiDelegate = self

extension ViewController: BarcodeFindViewUIDelegate {
func barcodeFindView(_ view: BarcodeFindView,
didTapFinishButton foundItems: Set<BarcodeFindItem>) {
navigationController?.popViewController(animated: true)
}
}

Start Searching

With everything configured, you can now start searching for items. This is done by calling barcodeFindView.startSearching().

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
barcodeFindView.startSearching()
}

This is the equivalent of pressing the Play button programmatically. It will start the search process, turn on the camera, and hide the item carousel.