Skip to main content

6. Run the Journey in your app

Your host app reaches Journeys through the JourneyService. The recommended path is SDK-provided UI: the SDK renders the Journey's screens itself in a styleable WebView, so your app only needs to fetch the Journey by name and run it.

The two functions you need are:

  • JourneyService.getJourneys(tags?, statuses?) — list available Journeys, optionally filtered by tag.
  • JourneyService.runJourney(name, data) — run a Journey by its programmatic name. data is an object whose keys are seeded into the JourneyContext before the first step.
let journeyService = DataSapien.getJourneyService()

// Either look it up by tag…
let journeys = try await journeyService.getJourneys(tags: ["getting-started"])

// …or just run it directly by programmatic name.
let result = try await journeyService.runJourney(
name: "hello_world",
data: [:]
)
Programmatic name

A Journey's programmatic name is the unique identifier you set on the Basics section in build the Journey (we used hello_world). It's what every API call refers to — not the display title.

Exact signatures

The native API surface is nearly identical to the JavaScript one shown above; Android methods may take an extra Context. See the JourneyService API reference for per-platform signatures.

Build and run your app on a device. Trigger the call above and the SDK will, in order:

  1. Show the favorite_color question.
  2. Show the "What's your name?" question.
  3. Run the Script step silently to build greeting.
  4. Show the Screen displaying Hello, <name>! Your favourite colour is <colour>.
  5. Complete.

Hello World running on a device

[#10] The Hello World Journey running on a device


What just happened

In a single Journey you used four of the five step types, defined a custom MeData, persisted a value to the on-device data vault, and ran user-authored logic — all without sending any personal data to a backend. That's the whole platform in miniature.

Next steps