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:
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:
  4. When prompted for Dependency Rule, choose:
    • Version → “Up to Next Major”
    • Starting from: 1.0.2
  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:

2. Initialize the SDK

Call Desmo.setup once at app startup, usually in your App’s init or in your AppDelegate.
  • 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. Request permissions

The SDK provides a helper to request all required permissions upfront. Call this during your app’s onboarding or before starting the first session:
You can also check permission status without prompting:
Requesting permissions upfront ensures sensor data flows immediately when a session starts. If you skip this step, the SDK will request permissions during startSession(), but the first few seconds of data may be missing while the user responds to the prompts.

4. Understanding session types

Every session requires a session type that indicates what the driver is doing:
For .pickup and .drop sessions, you must provide an address. For .transit sessions, the address is optional.

5. Understanding the Address model

The SDK provides a structured Address model for delivery locations:
Use structured addresses when possible — they provide better location context for delivery insights.

6. Start a delivery session

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

Required parameters

Optional parameters

Full example with all parameters

Behind the scenes, the SDK:
  • Calls Desmo’s backend to create a session.
  • Starts collecting telemetry on-device (IMU, GPS, barometer, magnetometer).
  • Begins batching telemetry to Desmo while the session is recording.
  • Persists data locally if offline and retries when connectivity returns.

7. Stop a delivery session

Call this when the delivery is complete:
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: