Getting started
The SDK is a native library in the existing driver app. iOS is a Swift package. Android is a Gradle module.
The SDK runs on iPhone and Android phones: iOS 16 and later, Android 10 and later. It does not run on iPad, or on Android 9 and earlier. The host app may still run on those devices. On iPad every call is rejected, state stays notReady, and beginTrip returns "". On some Huawei phones, background recording stops after a swipe.
The Android library declares minSdk 29. An app with minSdk 29 or higher needs nothing more. An app that still supports Android 9 or earlier adds <uses-sdk tools:overrideLibrary="com.yas.capture" /> to its manifest, and calls YasCapture only when Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q.
One phone holds one open trip. For a sole driver, that phone is one driver and one vehicle. To change the vehicle, call endTrip if a trip is open, then call setup again.
- On every cold start, including a relaunch by the system, call
registerAtLaunch. Callsetuponce the driver and vehicle are known. PasstokenProvideron everysetup. ThetokenProviderfrom the last launch is not kept. - Read
openTripId. It is null when no trip is open. A non-null value is the open trip, including whenstartTimeis still in the future. - When a booking starts, call
beginTripwith the trip id, the start time, and the job metadata. Recording cannot start beforestartTimeor before this call. On Android, it also waits for the app to be in the foreground. See Trips. IfopenTripIdis a different id, callendTripfor that trip first. IfopenTripIdis this id,beginTripreturns the existingsessionIdand leaves the trip unchanged. - When the booking ends, call
endTripwith the same trip id, the end time, and the job metadata at that time. If the app is in the background, call it the next time the app opens, and pass the actual end time. AtripIdother thanopenTripIdis rejected, and the open trip stays open. - The SDK sends the samples it recorded from the start of recording through
endTime, together with the metadata stored on the trip. It callstokenProviderwhen it needs a bearer. - Read
stateafter each call and when the app comes to the foreground. There is no listener. The values arenotReady,idle,recording,incomplete, andblocked. See Permissions.
Call registerAtLaunch before the app finishes launching, then read openTripId. The Android version below is an example. Use the version shipped with the SDK.
import YasCapture
func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { YasCapture.registerAtLaunch() if YasCapture.shared.openTripId != nil { // A trip is still open. See Trips. } return true}
func application( _ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) { YasCapture.handleEvents( forBackgroundURLSession: identifier, completionHandler: completionHandler ) // This hook does not call completionHandler. // Route the app's own session identifiers to their owner. // That owner calls completionHandler.}dependencies { implementation("com.yas.capture:mobile-sdk:1.0.0")}class DriverApp : Application() { override fun onCreate() { super.onCreate() YasCapture.registerAtLaunch(this) if (YasCapture.openTripId != null) { // A trip is still open. See Trips. } }}No call throws. A rejected beginTrip returns "". Do not save that as a sessionId. See Trips.
If capture is disabled for this driver, omit beginTrip. If beginTrip or endTrip fails, complete the booking as usual. The trace for that job will be missing or incomplete.
Next: Setup.
