Skip to main content

iOS Journey Service

Functions

syncJourneys

public func syncJourneys(
onSuccess: @escaping () -> Void,
onError: ((Error) -> Void)? = nil
)

Synchronize journey list with the Orchestrator.

Parameters:

  • onSuccess: () -> Void — Called when the sync operation completes successfully.
  • onError: ((Error) -> Void)? = nil — Called when an error occurs during sync.

getJourneys

public func getJourneys(
tags: [String] = [],
statuses: JourneyStatusFilter = [],
onSuccess: @escaping ([Journey]) -> Void,
onError: ((Error) -> Void)? = nil
) -> [Journey]

Fetch journeys from local storage, optionally filtered by tags and status.

Parameters:

  • tags: [String] — Optional filter list. Empty means no tag filtering.
  • statuses: JourneyStatusFilter — Optional status filter. Empty means no filtering.
  • onSuccess: ([Journey]) -> Void — Returns all matching journeys.
  • onError: ((Error) -> Void)? = nil — Error callback.

getJourney

public func getJourney(
name: String,
onSuccess: @escaping (Journey?) -> Void,
onError: ((Error) -> Void)? = nil
) -> Journey?

Retrieves a journey by its name from local storage.

Parameters:

  • name: String — Name of the journey.
  • onSuccess: (Journey?) -> Void — Returns the journey or nil.
  • onError: ((Error) -> Void)? = nil — Error callback.

getJourneyExecutionRecord

public func getJourneyExecutionRecord(
name: String,
onSuccess: @escaping (JourneyExecutionRecord?) -> Void,
onError: ((Error) -> Void)? = nil
) -> JourneyExecutionRecord?

Returns the latest execution record for the given journey.

Parameters:

  • name: String — Name of the journey.
  • onSuccess: (JourneyExecutionRecord?) -> Void — Latest execution record or nil.
  • onError: ((Error) -> Void)? = nil — Error callback.

getJourneyExecutionRecords

public func getJourneyExecutionRecords(
name: String,
onSuccess: @escaping ([JourneyExecutionRecord]?) -> Void,
onError: ((Error) -> Void)? = nil
) -> [JourneyExecutionRecord]?

Retrieves all execution records associated with the specified journey.

Parameters:

  • name: String — Name of the journey.
  • onSuccess: ([JourneyExecutionRecord]?) -> Void — List of execution records or nil.
  • onError: ((Error) -> Void)? = nil — Error callback.

getJourneyStatus

public func getJourneyStatus(
name: String,
onSuccess: @escaping (JourneyStatus) -> Void,
onError: ((Error) -> Void)? = nil
) -> JourneyStatus

Retrieves the current status of the specified journey.

Parameters:

  • name: String — Name of the journey.
  • onSuccess: (JourneyStatus) -> Void — The current status.
  • onError: ((Error) -> Void)? = nil — Error callback.

runJourney

public func runJourney(
_ viewController: UIViewController,
data: [String: Any] = [:],
name: String,
onSuccess: @escaping (([String: Any]) -> Void),
onError: @escaping ((Error) -> Void)? = nil
) -> [String: Any]

Launches the specified journey UI and returns its output data upon completion.

Parameters:

  • viewController: UIViewController — Host view controller used to present UI.
  • data: [String: Any] — Optional initial payload.
  • name: String — Journey name.
  • onSuccess: ([String: Any]) -> Void — Resulting output data.
  • onError: ((Error) -> Void)? = nil — Error callback.

Classes

Journey

public struct Journey: Codable {
public var id: String
public var name: String
public var flow: JourneyFlow
public var metadata: JourneyMetadata
public var tags: [String]?
public var zpdRequest: JourneyZPDRequest?
public var createdAt: Double
public var updatedAt: Double?
public var publishedAt: Double?
}

JourneyMetadata

public struct JourneyMetadata: Codable {
public var title: String
public var description: String?
public var imageUrl: String?
}

JourneyZPDRequest

public struct JourneyZPDRequest: Codable {
public var requested: [FlowData]?
}

JourneyFlow

public struct JourneyFlow: Codable {
public var xml: String
public var data: [FlowData]
}

JourneyFlowData

public struct FlowData: Codable {
public var name: String
public var source: String
public var origin: String?
public var type: String
}

JourneyExecutionRecord

public struct JourneyExecutionRecord: Codable {
public var id: String
public var status: String
public var date: TimeInterval
public var journeyContext: JourneyContext?
}

JourneyContext

public class JourneyContext: Codable {
private var values: [String: Any] = [:]

public init(values: [String: Any] = [:]) {
self.values = values
}
}

JourneyStatus

public enum JourneyStatus: String {
case SENT
case COMPLETED
case NOTSTARTED
}

JourneyStatusFilter

public typealias JourneyStatusFilter = Set<JourneyStatus>