Scan Process - Overview
The API documentation for the current version (13.0.1) is available here. |
TireTreadScanView
The scanning process is performed entirely through the TireTreadScanView , and can only be conducted in Landscape mode.
The |
The TireTreadScanView
is a UI element that can be added as a subview to your page.
This element automatically handles camera access, permission request, and scan guidance (via the Default UI), so you can simply listen to the callbacks to seamlessly integrate it into your app’s workflow.
-
Android
-
iOS
TireTreadScanView(
onScanAborted = ::onScanAborted,
onScanProcessCompleted = ::showResult,
callback = null,
onError = { measurementUUID, exception ->
/* Handle initialization error */
finish()
})
TireTreadScanViewKt.TireTreadScanView(
onScanAborted: onScanAborted,
onScanProcessCompleted: showResult,
callback: nil
) { measurementUUID, error in
print("Initialization failed: \(error)")
DispatchQueue.main.async {
self.navigationController?.popViewController(animated: true)
}
}
Tire Width
To increase the accuracy of scans and compatibility with the broad range of Android device models on the market, the TireTreadScanView
on Android will automatically request the user to provide the width of the tire being scanned (see TireWidthInput).
If this information is already available in your system(e.g., from scanning with the
Anyline Tire Sidewall Scanners) you can provide it directly to the tireWidth
parameter of the
TireTreadScanView, thus skipping the TireWidthInput
screen step.
For example:
If your system contains a string formatted like "255/65R17", the three-digit number preceding the “/” represents the tire width (in this case, 255). If the tire width is embedded within a full string, you can extract it using string manipulation techniques such as regular expressions or the split function.
After extracting the number, verify that it is an integer between 100 and 500. If it meets this requirement, pass it to the Tire Tread SDK using the config parameter (scanConfig.tireWidth). If the number does not fall within this range, it is not a valid tire width. In this case, you can ignore the parameter (thus sending null to it), prompting the TireWidthInput screen to automatically appear for the user.
fun extractTireWidthFromTireSizeString(tireSizeString: String): Int? {
val regex = Regex("""[A-Za-z]*\d{3}""")
val match = regex.find(tireSizeString)
val tireWidth = match?.value?.filter { it.isDigit() }?.take(3)?.toIntOrNull()
return if (tireWidth in 100..500) {
tireWidth
} else {
null
}
}
/* usage: */
val extractedTireWidth = extractTireWidthFromTireSizeString(tireSizeString) // e.g. "P255/65R17"
println(extractedTireWidth) // Output: 255
// provide the extractedTireWidth to the "tireWidth" parameter of the ScanConfig.
TireTreadScanView(
config = TireTreadConfig().apply {
scanConfig.tireWidth = extractedTireWidth
},
onScanAborted = ::onScanAborted,
onScanProcessCompleted = ::openResultScreen,
callback = null,
onError = { measurementUUID, exception ->
// handle any errors
})
On iOS, the tire width is not necessary, and the input screen will not be displayed.
TireTreadConfig
The TireTreadScanView can be used directly without any additional configuration.
To modify the behavior, appearance, or metadata of the scan process, you can either use the TireTreadConfig object or a JSON representation of it.
The TireTreadConfig
provides, out of the box, everything needed for a successful scan, so you only need to change the specific properties that you want to modify!
Refer to the TireTreadConfig KDoc for a full list of properties, their description and default values.
Audio Feedback
The Tire Tread SDK can provide audio feedback to guide users to position the device correctly through the scan process.
To make use of these audio feedbacks, your application needs to provide (and thus can customize) the audio files inside its Assets
(Android) or Resources
(iOS) folder.
The audio feedbacks (with their respective files names) are played on:
-
Focus Point Found (iOS only)
-
tiretread_focuspoint_found.wav
-
-
Scan Started
-
tiretread_sound_start.wav
-
-
Scan Stopped
-
tiretread_sound_stop.wav
-
-
Phone too close to the Tire
-
tiretread_sound_beep_too_close.wav
-
-
Phone too distant from the Tire
-
tiretread_sound_beep_too_far.wav
-
The SDK only supports these file names, and the .wav
extension.
An example implementation, and the example audio files, can be found in our Android and iOS GitHub Example implementation.
To disable the audio feedback completely, remove these audio files from your application’s resources or rename them. |
Handling the TireTreadScanView
events
The TireTreadScanView
communicates back to your application via callback functions.
When using the default UI, your application only needs to implement behavior for the following callbacks from the SDK:
-
onScanAborted
: Invoked when the scanning process is aborted -
onScanProcessCompleted
: Invoked when the scanning process is completed -
onError
: Invoked when the scanning process ran into an error
Implementing behaviour for the To ignore it on Android and iOS, assign it to |
Scan Guide
Before starting, check out the quick How to Measure Tire Tread guide to learn how to perform the perfect scan!
Once you are able to perform the scans, head to the Results page to learn how to handle the measurement results.