Skip to content

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.

  1. On every cold start, including a relaunch by the system, call registerAtLaunch. Call setup once the driver and vehicle are known. Pass tokenProvider on every setup. The tokenProvider from the last launch is not kept.
  2. Read openTripId. It is null when no trip is open. A non-null value is the open trip, including when startTime is still in the future.
  3. When a booking starts, call beginTrip with the trip id, the start time, and the job metadata. Recording cannot start before startTime or before this call. On Android, it also waits for the app to be in the foreground. See Trips. If openTripId is a different id, call endTrip for that trip first. If openTripId is this id, beginTrip returns the existing sessionId and leaves the trip unchanged.
  4. When the booking ends, call endTrip with 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. A tripId other than openTripId is rejected, and the open trip stays open.
  5. The SDK sends the samples it recorded from the start of recording through endTime, together with the metadata stored on the trip. It calls tokenProvider when it needs a bearer.
  6. Read state after each call and when the app comes to the foreground. There is no listener. The values are notReady, idle, recording, incomplete, and blocked. 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.
}

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.