Scan Process - iOS

The AnylineTireTreadSDK allows for a variety of options on how to set up the scan process. In the following sections we will show the most convenient and quick way to get started with scanning.

You can check out our iOS GitHub repository for a complete example implementation of the TireTreadScanView.

Implementing the ScannerViewControllerHolder Interface

To set up the TireTreadScanView and retrieve the scan view controller, your UIViewController subclass should implement the ScannerViewControllerHolder interface.

This interface gives your view controller two properties:

  1. scannerViewController: After the setup call TireTreadScanViewKt.TireTreadScanView (see below) is successfully made, this property will hold the instance of the TireTreadScannerViewController, which handles the scanning process.

  2. dismissViewController: This is a function property that will be called by the SDK when a request has been made to dismiss the scanner. Assign it a block within the lifetime of your ScannerViewControllerHolder that handles this scenario in the appropriate manner.

Here is an example of how to implement the ScannerViewControllerHolder interface:

class YourViewController: UIViewController, ScannerViewControllerHolder {

    // Implement the properties defined by the ScannerViewControllerHolder interface
    var scannerViewController: UIViewController?

    var dismissViewController: (() -> Void)?

    // Rest of your class implementation...
}

Remember to replace YourViewController with the actual name of your view controller.

Make sure that YourViewController runs in Landscape mode.

Setting up the Scan View Controller

Once the SDK has been initialized and the necessary permissions have been granted, you can set up the scan view controller.

  • With config object

  • With JSON config

private func setupTireTreadScanView() {

    let config = TireTreadScanViewConfig()
    /* if needed, you can customize the config, e.g.: */

    // config.measurementSystem = .imperial

    // let customUiConfig = DefaultUiConfig()
    // customUiConfig.tapToStartScanningTooltipConfig.textOk = "Start scanning now"
    // config.defaultUiConfig = customUiConfig

    // config.additionalContext = additionalContext

    // creates a TireTreadScannerViewController. You can later refer to it here
    // as self.scannerViewController.
    TireTreadScanViewKt.TireTreadScanView(
        context: self,
        config: config,
        onScanAborted: onScanAborted,
        onScanProcessCompleted: onScanProcessCompleted,
        callback: { event in
            // Optionally, you can listen to all the scan events to build custom workflows
        }) { measurementUUID, error in
        // Handle errors during scanning process
    }
}

private func addScanViewControllerAsChild() {
    guard let scannerViewController = scannerViewController else {
        // Handle error
        return
    }
    addChild(scannerViewController)
    view.addSubview(scannerViewController.view)
    scannerViewController.didMove(toParent: self)
}
private func setupTireTreadScanView() {


    TireTreadScanViewKt.TireTreadScanView(
        context: self,
        config: "my_scan_config.json", // You can also use the full JSON string as an input!
        onScanAborted: onScanAborted,
        onScanProcessCompleted: onScanProcessCompleted
        callback: nil
    ) { measurementUUID, error in
        // Handle errors during scanning process
    }
}

private func addScanViewControllerAsChild() {
    guard let scannerViewController = scannerViewController else {
        // Handle error
        return
    }
    addChild(scannerViewController)
    view.addSubview(scannerViewController.view)
    scannerViewController.didMove(toParent: self)
}

private func onScanAborted(measurementUUID: String?) {
    // handle scan aborted, e.g. leave the screen
}

private func onScanProcessCompleted(measurementUUID: String) {
    // handle scan process completed, e.g. show a results page
}
You can check out our GitHub example repository for an implementation of the ScanViewController.

Check out the next section to learn how to handle the measurement results after the scan process is finished.