Connecting with other Anyline scans

To connect your scans with one of our other Anyline capabilities you can pass a correlationId with the additionalContext either via a JSON configuration file or in code.

The correlationId has to be a valid UUID otherwise the SDK will return an InvalidUUIDException in the initialization callback.

  • JSON

  • Android

  • iOS

{
  "useDefaultUi": true,
  "useDefaultHaptic": true,
  "defaultUiConfig": {
    "distanceIndicatorConfig": {
      "visible": true,
      "textOk": "Mantenha a distância.",
      "textMoveCloser": "Chegue mais perto.",
      "textMoveAway": "Aumente a distância."
    },
    "focusPointTooltipConfig": {
      "visible": true,
      "text": "Mova o dispositivo para frente e para trás para detectar o pneu."
    },
    "tapToStartScanningTooltipConfig": {
      "visible": true,
      "text": "Toque na tela para iniciar o processo."
    },
    "tireOverlayConfig": {
      "visible": true
    },
    "uploadViewConfig": {
      "visible": true,
      "text": "Enviando imagens, aguarde."
    },
    "orientationWarningConfig": {
      "visible": true,
      "text": "Please rotate the phone to landscape mode"
    }
  },
  "scanSpeed": "Fast",
  "measurementSystem": "Metric",
  "additionalContext": {
    "tirePosition": {
      "axle": 1,
      "side": "Left",
      "positionOnAxle": 1
    },
    "correlationId": "00000000-0000-0000-0000-000000000000"
  }
}
@Composable
fun TireTreadScanViewWithTireTreadScanViewConfig() {
    // Define the values for your config
    val tireTreadScanViewConfig = TireTreadScanViewConfig().apply {
        additionalContext = AdditionalContext().apply {
            correlationId = "00000000-0000-0000-0000-000000000000"
        }
    }

    // Invoke the TireTreadScanView composable with the TireTreadScanViewConfig above
    TireTreadScanView(context = this,
        config = tireTreadScanViewConfig,
        onScanAborted = ::onScanAborted,
        callback = ::handleEvent
    ) { measurementUUID, exception ->
        // handle errors during the scan process
    }
}

private fun onScanAborted(measurementUUID: String?) {
    // handle scan aborted
}

private fun handleScanEvent(event: ScanEvent) {
    when (event) {
        is OnUploadCompleted -> onUploadCompleted(event.uuid)
        is OnImageUploaded -> {
            Log.i(
                getString(R.string.app_name),
                "onImageUploaded: ${event.uploaded}/${event.total}"
            )
        }

        // When not using the "default UI", use this event to provide guidance to the users
        is OnDistanceChanged -> onDistanceChanged(event.uuid, event.previousStatus, event.newStatus, event.previousDistance, event.newDistance)

        else -> {
            Log.i(getString(R.string.app_name), event.toString())
        }
    }
}
private func setupTireTreadScanView() {
    let config = TireTreadScanViewConfig()

    let additionalContext = AdditionalContext()

    // set correlation ID
    additionalContext.correlationId = "00000000-0000-0000-0000-000000000000"
    config.additionalContext = additionalContext

    TireTreadScanViewKt.TireTreadScanView(
        context: self,
        config: config,
        onScanAborted: onScanAborted,
        onScanProcessCompleted: onScanProcessCompleted,
        callback: handleScanEvent
    ) { [weak self] measurementUUID, error in
        // handle errors during scanning process
    }

    self.dismissViewController = { [weak self] in
        self?.navigationController?.popViewController(animated: true)
    }
    addScanViewControllerAsChild()
}

private func onScanAborted(measurementUUID: String?) {
    // handle scan aborted event
}

private func onScanProcessCompleted(measurementUUID: String) {
    // handle scan process finished
    // start fetching result
}

private func handleScanEvent(event: ScanEvent) {
    switch(event) {

    case let event as OnImageUploaded:
        print("onImageUploaded: \(event.total) images uploaded in total")
        break

    // handle other events

    default:
        print("ScanEvent: \(event.description)")
        break
    }
}