iOS SDK - Getting Started
Quick Start Guide
This guide will lead you through the first steps of integrating the Anyline Tire Tread SDK into your iOS app.
You can check out our GitHub repository for a full example implementation of the Anyline Tire Tread SDK. |
Add the Anyline Tire Tread SDK as dependency
The Anyline Tire Tread SDK for iOS is available via CocoaPods and Swift Package Manager.
CocoaPods
Add the following line to your Podfile:
pod 'AnylineTireTreadSdk'
Run pod install
in the terminal in the same directory as your Podfile
.
Swift Package Manager
In Xcode, go to File → Swift Packages → Add Package Dependency
and enter the framework’s repository URL: https://github.com/Anyline/anyline-tiretread-spm-module
After adding the dependency, import the framework into your native iOS application with the following line:
import AnylineTireTreadSdk
The Anyline Tire Tread SDK follows the Semantic Versioning. |
Integrate the Anyline License Key
A License Key string will be required in order to run the Anyline Tire Tread SDK on your app.
Store the License Key
You can integrate your license key string in a way that best suits your development workflow. A recommended method is to store the key within the system keychain.
Initialize the iOS Tire Tread SDK with the License Key
Initialize the Anyline Tire Tread SDK – and handle any exceptions thrown – before doing anything related to the SDK.
Here is an example on how to do it:
// This must be called before doing anything else with the AnylineTireTreadSdk.
// It only needs to be called once during your application life-cycle.
func tryInitializeSdk(context: UIViewController) {
do {
let licenseKey = "<your-license-key>"
try AnylineTireTreadSdk.shared.doInit(licenseKey: licenseKey)
// continue the setup after successful initialization
} catch {
// handle initialization error
}
}
In the code above, replace <your-license-key> with your actual license key.
|
This function attempts to initialize AnylineTireTreadSdk
with the provided license key. If the SDK fails to initialize, you should handle this error appropriately.
Check Camera Permissions
Before starting the scan process, it is crucial to check and request camera permission, as it is required for the SDK to function correctly.
First, in your application’s Info.plist file, add an NSCameraUsageDescription
string value which explains
to your users why the app would be requiring camera permission access from them.
Then, right before requesting for a scan view from the SDK, call the following:
func requestPermissionsAndProceed() {
let cameraAuthorizationStatus = AVCaptureDevice.authorizationStatus(for: .video)
switch cameraAuthorizationStatus {
case .authorized:
// Continue with setup
case .notDetermined:
AVCaptureDevice.requestAccess(for: .video) { granted in
DispatchQueue.main.async {
if granted {
// Continue with setup
} else {
// Handle denied access
}
}
}
default:
// Handle other cases
}
}
In the next section, you will learn how to integrate the TireTreadScanView
to start scanning and measuring tires with your application.