Skip to main content

What you’ll build

In this quickstart you will:
  • Install the Desmo iOS SDK via Swift Package Manager.
  • Initialize the SDK with your publishable key.
  • Start and stop a delivery session from your app.
This page assumes you already have a Desmo account and at least one publishable key that starts with pk_....
If you don’t have a key yet, contact your Desmo representative to have one issued for your project.

Requirements

  • iOS 15.0 or later
  • Xcode 15 or later
  • Swift 5.9 or later

App permissions

To let Desmo record sessions correctly, your app should request:
  • Location – so sessions can be tied to where the delivery happened.
  • Motion & Fitness – so Desmo can interpret movement patterns during the session.
Add these keys to your Info.plist with user-facing explanations that match your product:
<key>NSLocationWhenInUseUsageDescription</key>
<string>We use your location during active deliveries to record proof of delivery.</string>
<key>NSMotionUsageDescription</key>
<string>We use motion data during active deliveries to understand movement for proof of delivery.</string>
You can customize the strings, but keep the intent clear: data is only used during active deliveries to power Desmo’s proof‑of‑delivery intelligence.

1. Install the SDK (Swift Package Manager)

You can add the SDK either through Xcode or by editing your own Package.swift.

Option 1 – Add via Xcode UI

  1. In Xcode, open your app project.
  2. Go to File → Add Package Dependencies…
  3. In the search field, paste the package URL:
    https://github.com/kubocreate/desmo-iOS-sdk.git
    
  4. When prompted for Dependency Rule, choose:
    • Version → “Up to Next Major”
    • Starting from: 0.1.1
  5. Select the product DesmoTraceSDK for your app target and finish.
If you previously added the SDK code manually (for example, as a local project), remove that and keep only the SPM package to avoid duplicates.

Option 2 – Add to Package.swift

If you use SwiftPM directly, add this to your app’s Package.swift:
dependencies: [
    .package(
        url: "https://github.com/kubocreate/desmo-iOS-sdk.git",
        from: "0.1.1"
    )
],
targets: [
    .target(
        name: "YourAppTarget",
        dependencies: [
            .product(name: "DesmoTraceSDK", package: "DesmoTraceSDK")
        ]
    )
]

2. Initialize the SDK

Call Desmo.setup once at app startup, usually in your App’s init or in your AppDelegate.
import SwiftUI
import DesmoTraceSDK

@main
struct YourApp: App {
    init() {
        Desmo.setup(
            key: "pk_sandbox_XXXXXXXXXXXXXXXX",  // your Desmo publishable key
            environment: .sandbox                // use .live in production
        )
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
  • key: your publishable Desmo API key (starts with pk_).
  • environment:
    • .sandbox – Desmo sandbox environment.
    • .live – Desmo production environment.
If Desmo.setup fails (for example, if the key does not start with pk_), the SDK will log an error and Desmo.shared will remain nil.

3. Start a delivery session

Call this when you begin recording a delivery (for example, when the driver starts a drop-off):
import DesmoTraceSDK

func startDeliverySession() async {
    guard let client = Desmo.shared else {
        print("Desmo SDK is not configured")
        return
    }

    do {
        let session = try await client.startSession(
            deliveryId: "DELIVERY_123",
            address: "123 Main Street, City"
        )
        print("Started session: \(session.sessionId)")
    } catch {
        print("Failed to start session: \(error)")
    }
}
Behind the scenes, the SDK:
  • Calls Desmo’s backend to create a session.
  • Starts collecting telemetry on-device.
  • Begins batching telemetry to Desmo while the session is recording.

4. Stop a delivery session

Call this when the delivery is complete:
func stopDeliverySession() async {
    guard let client = Desmo.shared else {
        print("Desmo SDK is not configured")
        return
    }

    do {
        let session = try await client.stopSession()
        print("Stopped session: \(session.sessionId)")
    } catch {
        print("Failed to stop session: \(error)")
    }
}
When you stop the session, the SDK:
  • Flushes any remaining telemetry.
  • Notifies the backend that the session is complete.
  • Lets Desmo’s workers start processing PoD intelligence for that session.

Next steps

From here: