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. |
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
var scannerViewController: UIViewController?
private func setupTireTreadScanView() {
let customConfig = TireTreadConfig()
/* if needed, you can customize the config, e.g.: */
// let customUiConfig = UIConfig()
// customUiConfig.tapToStartScanningTooltipConfig.textOk = "Start scanning now"
// customUiConfig.measurementSystem = .imperial
// customConfig.uiConfig = customUiConfig
// customConfig.additionalContext = AdditionalContext()
// customConfig.additionalContext.correlationId = UUID().uuidString
// The config parameter is optional, and can safely be ignored if no modifications are required.
self.scannerViewController = TireTreadScanViewKt.TireTreadScanView(
config: customConfig,
onScanAborted: onScanAborted,
onScanProcessCompleted: onScanProcessCompleted,
callback: nil
) { measurementUUID, error in
print("Initialization failed: \(error)")
DispatchQueue.main.async {
self.dismiss(animated: true)
}
}
addScanViewControllerAsChild()
}
private func addScanViewControllerAsChild() {
guard let scannerViewController = scannerViewController else {
// Handle error
return
}
addChild(scannerViewController)
view.addSubview(scannerViewController.view)
scannerViewController.didMove(toParent: self)
}
private func setupTireTreadScanView() {
self.scannerViewController = TireTreadScanViewKt.TireTreadScanView(
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
print("Initialization failed: \(error)")
DispatchQueue.main.async {
self.navigationController?.popViewController(animated: true)
}
}
}
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.