Tire Sidewall Scanner
The Tire Sidewall Scanner is a convenience feature that handles a tire-sidewall reading end to end, so you don’t have to integrate the Anyline Cloud API yourself. It presents a guided, full-screen camera experience that walks the user through aligning the tire and captures the sidewall automatically once it is correctly framed - there is no manual shutter to wire up. It then uploads the photo to the Anyline Cloud API on your behalf and returns the structured reading together with the captured image.
You launch it, the user scans, and you receive a single TswScanResult in your callback - no Cloud API request to build, and no capture logic to manage.
What you need
-
A Cloud API client ID - a string that authenticates the upload to the Anyline Cloud API. This is separate from your SDK license key; it is provided by Anyline.
-
Camera permission. The scanner requests it at runtime. On iOS, add an
NSCameraUsageDescriptionentry to yourInfo.plist(see Getting Started).
Check device support
Before launching, you can confirm the device can run the scanner. isSupported() returns a TswSupportStatus and does not require the SDK to be initialized.
-
TswSupportStatus.Supported- the device can run the scanner. -
TswSupportStatus.Unavailable- carries anerror(SdkError) and auserResolvableflag. On Android, whenuserResolvableistrue(e.g. Google Play Services needs an update), callAnylineTireSidewallScanner.resolvePlayServices(activity)to show the system resolution dialog.
-
Android
-
iOS
import io.anyline.tiretread.sdk.api.AnylineTireSidewallScanner
import io.anyline.tiretread.sdk.api.TswSupportStatus
// isSupported() is a suspend function - call it from a coroutine.
when (val status = AnylineTireSidewallScanner.isSupported()) {
is TswSupportStatus.Supported -> {
// Ready to scan
}
is TswSupportStatus.Unavailable -> {
// status.error: SdkError describing why
if (status.userResolvable) {
AnylineTireSidewallScanner.resolvePlayServices(activity)
}
}
}
On iOS the scanner is supported on every device that meets the framework’s minimum iOS version, so isSupported() always reports Supported. You can proceed directly to launching a scan.
Launch a scan
Call scan(…) with the host, your Cloud API client ID, and an optional TswScannerConfig. The result is delivered once to the onResult callback.
| Input | Description |
|---|---|
|
The host that presents the scanner - an Android |
|
Your Anyline Cloud API client ID. |
|
Optional |
|
Callback invoked exactly once with a |
-
Android
-
iOS
import io.anyline.tiretread.sdk.api.AnylineTireSidewallScanner
import io.anyline.tiretread.sdk.api.TswScanResult
AnylineTireSidewallScanner().scan(
from = context,
clientId = "<YOUR_CLOUD_API_CLIENT_ID>",
) { result ->
when (result) {
is TswScanResult.Completed -> { /* see "The result" below */ }
is TswScanResult.Failed -> { /* result.error: SdkError */ }
TswScanResult.Aborted -> { /* user cancelled before capture */ }
}
}
import AnylineTireTreadSdk
AnylineTireSidewallScanner().scan(
from: self,
clientId: "<YOUR_CLOUD_API_CLIENT_ID>"
) { result in
if let completed = result as? TswScanResult.Completed {
// see "The result" below
} else if result is TswScanResult.Aborted {
// user cancelled before capture
} else if let failed = result as? TswScanResult.Failed {
// failed.error: SdkError
}
}
|
|
The result
TswScanResult is one of three outcomes:
| Outcome | Meaning |
|---|---|
|
Capture and upload both succeeded. Carries the fields below. |
|
The scan could not be completed. Carries an |
|
The user dismissed the scanner before a capture was taken. |
Completed exposes:
| Field | Type | Description |
|---|---|---|
|
|
The raw JSON response from the Anyline Cloud API containing the sidewall reading (e.g. the tire size). Parse it with your JSON library of choice. |
|
|
The captured sidewall image, upright and ready to display or store. On iOS this is a |
|
|
Capture metadata. Currently exposes |
|
|
TswScanMetadata.environmentLighting is an EnvironmentLighting? describing the ambient lighting at capture - Dark, Bright, or Good - or null if no reading was available.
-
Android
-
iOS
is TswScanResult.Completed -> {
val json = result.resultJson // reading (JSON)
val image = result.imageBytes // captured image
val lighting = result.scanMetadata.environmentLighting // Dark / Bright / Good / null
}
if let completed = result as? TswScanResult.Completed {
let json = completed.resultJson // reading (JSON)
let image = completed.imageBytes.toNSData() // captured image
let lighting = completed.scanMetadata.environmentLighting // Dark / Bright / Good / nil
}
Configuration
TswScannerConfig is optional. Construct it, override only what you need, and pass it to scan(…).
| Field | Type | Description |
|---|---|---|
|
|
Optional ID to correlate this scan with other Anyline scans (e.g. a matching Tire Tread scan). Must be a version-4 UUID when set; an invalid value fails the scan with |
|
|
Overridable UI strings shown on the scanner overlay. Set individual entries ( |
-
Android
-
iOS
import io.anyline.tiretread.sdk.tsw.ui.configs.TswScannerConfig
val config = TswScannerConfig().apply {
correlationId = workflowUuid // optional, v4 UUID
texts.textAlignTire = getString(R.string.tsw_align_tire) // optional localization
}
AnylineTireSidewallScanner().scan(from = context, clientId = clientId, config = config) { result ->
// ...
}
let config = TswScannerConfig()
config.correlationId = workflowUuid // optional, v4 UUID
config.texts.textAlignTire = NSLocalizedString("tsw_align_tire", comment: "") // optional localization
AnylineTireSidewallScanner().scan(from: self, clientId: clientId, config: config) { result in
// ...
}
Errors
A Failed result carries an SdkError. The codes a sidewall scan can surface include:
| Code | When |
|---|---|
|
The Cloud API client ID is missing, invalid, or not authorized. |
|
Camera permission was not granted. |
|
The device is offline or the upload timed out. |
|
The image could not be processed by the backend. |
|
The supplied |
|
A sidewall scan is already in progress. |
See Errors for the full SdkError structure.
API reference
Generated reference documentation for the public types on this page (each opens in a new tab):
-
AnylineTireSidewallScanner - the scanner entry point (
scan(),isSupported()), listed in theapipackage reference. -
TswScanResult - the scan outcome (
Completed,Failed,Aborted). -
TswScanMetadata and EnvironmentLighting - capture metadata.
-
TswSupportStatus - the device-support result.
-
TswScannerConfig - scan configuration.
-
TswScannerTexts - all overridable overlay strings.