A lightweight native Swift SDK for integrating Passage into iOS apps. This document focuses on the external, user‑facing API only.
- iOS 13+
- Swift 5+
- Xcode 13+
Add the package in Xcode:
- File → Add Package Dependencies
- Enter the repository URL
- Choose a version and add to your app target
Or in Package.swift
:
dependencies: [
.package(url: "https://github.com/tailriskai/passage-swift.git", from: "0.0.1")
]
Add to your Podfile
and pod install
:
pod 'PassageSDK'
import PassageSDK
Passage.shared.configure(
PassageConfig(
debug: true // Optional
)
)
// If you already have an intent token
Passage.shared.open(
token: "your_intent_token",
presentationStyle: .modal, // .modal (default) or .fullScreen
from: viewController, // Optional; provide when presenting from a specific VC
onConnectionComplete: { data in
print("Connection complete: \(data.connectionId)")
},
onConnectionError: { error in
print("Error: \(error.error)")
},
onDataComplete: { result in
print("Data: \(String(describing: result.data))")
},
onPromptComplete: { prompt in
print("Prompt: \(prompt.key) = \(prompt.value)")
},
onExit: { reason in
print("Closed (reason: \(reason ?? "unknown"))")
}
)
// Or use the options-based API
let options = PassageOpenOptions(
intentToken: "your_intent_token",
onConnectionComplete: { data in /* ... */ },
onConnectionError: { error in /* ... */ },
onDataComplete: { result in /* ... */ },
onPromptComplete: { prompt in /* ... */ },
onExit: { reason in /* ... */ },
presentationStyle: .modal
)
Passage.shared.open(options, from: viewController)
Passage.shared.close()
public struct PassageConfig {
public init(
baseUrl: String? = nil,
socketUrl: String? = nil,
socketNamespace: String? = nil,
debug: Bool = false
)
}
Use defaults in production. Only override URLs for custom environments.
// Singleton
Passage.shared
// Configure SDK
func configure(_ config: PassageConfig)
// Open connection UI
func open(
token: String,
presentationStyle: PassagePresentationStyle = .modal,
from viewController: UIViewController? = nil,
onConnectionComplete: ((PassageSuccessData) -> Void)? = nil,
onConnectionError: ((PassageErrorData) -> Void)? = nil,
onDataComplete: ((PassageDataResult) -> Void)? = nil,
onPromptComplete: ((PassagePromptResponse) -> Void)? = nil,
onExit: ((String?) -> Void)? = nil
)
// Options-based overload
func open(_ options: PassageOpenOptions = PassageOpenOptions(), from viewController: UIViewController? = nil)
// Close connection UI
func close()
public enum PassagePresentationStyle {
case modal
case fullScreen
}
public struct PassageSuccessData {
public let connectionId: String
public let history: [PassageHistoryItem]
}
public struct PassageHistoryItem {
public let structuredData: Any?
public let additionalData: [String: Any]
}
public struct PassageErrorData {
public let error: String
public let data: Any?
}
public struct PassageDataResult {
public let data: Any?
public let prompts: [[String: Any]]?
}
public struct PassagePromptResponse {
public let key: String
public let value: String
public let response: Any?
}
public struct PassageOpenOptions { /* contains: intentToken, callbacks, presentationStyle */ }
Open Example/PassageExample.xcodeproj
, build, and run. Provide an intent token, then tap "Connect with Passage".
- Open an issue on GitHub
- Email [email protected]
- Visit
https://getpassage.ai
See LICENSE
.