Results

Obtaining the Measurement Results

After the upload of your scanned frames is completed (that is, when the TireTreadScanView 's callback method onUploadCompleted is invoked), your measurement results may still take a few seconds to become available. To fetch the results, your application should implement a polling logic.

We recommend fetching results once every 3 seconds, until the result – or failure – becomes available. The results can be fetched and obtained using the function getTreadDepthReportResult(measurementUuid), i.e..:

func startDataProcessing() {
    DispatchQueue.global().asyncAfter(deadline: .now() + 10) { [weak self] in
        self?.fetchTreadDepthResult()
    }
}

private func fetchTreadDepthResult() {
    AnylineTireTreadSdk.companion.getTreadDepthReportResult(
        measurementUuid: self.uuid,
        onGetTreadDepthReportResultSucceed: { [weak self] response in
            response.body { resultDTO, error in
                guard let self = self else { return }
                guard let status = resultDTO?.measurement.status else {
                    self.loadingViewModelDelegate?.displayError()
                    return
                }

                self.handleTreadDepthResult(treadDepthResult: resultDTO?.result, status: status)
            }
        },
        onGetTreadDepthReportResultFailed: { [weak self] response, exception in
            self?.loadingViewModelDelegate?.displayError()
        }
    )
}
Trying to obtain results more than once every 2 seconds will not result in any performance increase nor in faster results.

PDF Report

As with the results, to retrieve the PDF report of a measurement, you can poll the function getTreadDepthReportPdf(uuid) from the AnylineTireTreadSdk class every 3 seconds, until the PDF is available and returned as a byte array. The return value can then be saved and displayed as best fitting your application’s workflow, e.g.:

// Request PDF
func requestPDF(context: UIViewController) async {
    do {
        let kotlinByteArray = anylineSDK.getTreadDepthReportPdf(measurementUuid: self.uuid) { _ in
            print("PDF fetched from SDK.")
        }

        // Convert Kotlin ByteArray to Swift Data
        let data = kotlinByteArray.toNSData()

        self.resultDetailsViewModelDelegate?.showPDF(pdfData: data)
    } catch {
        resultDetailsViewModelDelegate?.showError(error: "error.description".localized())
    }
}

Remember to do/catch the getTreadDepthReportPdf() function, as the PDF report may not yet be available.

The PDF report will only be available if the TreadDepthResult was previously available, so the best workflow is to first check for results, and only then try to obtain the PDF report.

User Corrected Values and Comments

User Comments

To send a comment on a measurement, use the sendCommentFeedback function of the AnylineTireTreadSdk.

As usual with the TireTreadSDK, the UUID for the scan must be passed as a parameter. The comment is passed as a string:

func postFeedbackComment(uuid: String, comment: String) {
    DispatchQueue.global().async {
        AnylineTireTreadSdk.companion.sendCommentFeedback(
            resultUuidString: uuid,
            comment: comment,
            onSendCommentSucceed: { [weak self] response in
                response.body { resultDTO, error in
                    guard let self = self else { return }

                    if let error = error {
                        DispatchQueue.main.async {
                            self.feedbackViewModelDelegate?.showError(error: error.asAFError?.responseCode ?? 0)
                        }
                        return
                    }

                    // Handle success
                    DispatchQueue.main.async {
                        self.feedbackViewModelDelegate?.didSendData()
                    }
                }
            },
            onSendCommentFailed: { [weak self] response, exception in
                DispatchQueue.main.async {
                    self?.feedbackViewModelDelegate?.showError(error: 0)
                }
            }
        )
    }
}

User-Corrected Region Values

To send user-corrected region values, use the sendTreadDepthResultFeedback function from the AnylineTireTreadSdk. The result feedback should be provided as a list of TreadResultRegion, ordered from left to right.

You can only provide feedback for the regions returned by the SDK in the TreadDepthResult object.

The values of all regions need be added to the list before sending the feedback.

The TreadResultRegion objects can be initialized with millimeter or inch units:

func sendTreadDepthFeedback(resultUuid: String, treadResultRegions: [TreadResultRegion]) {
    DispatchQueue.global().async {
        AnylineTireTreadSdk.companion.sendTreadDepthResultFeedback(
            resultUuid: resultUuid,
            treadResultRegions: treadResultRegions,
            onSendTreadDepthResultSucceed: { [weak self] response in
                response.body { resultDTO, error in
                    guard let self = self else { return }

                    if let error = error {
                        DispatchQueue.main.async {
                            self.feedbackViewModelDelegate?.showError(error: error.asAFError?.responseCode ?? 0)
                        }
                        return
                    }
                }
            },
            onSendTreadDepthResultFailed: { [weak self] response, exception in
                DispatchQueue.main.async {
                    self?.feedbackViewModelDelegate?.showError(error: 0)
                }
            }
        )
    }
}