Swift Integration
Current native iOS Persona guide covering OnairosConfig, createConnectButton, and Swift connector customization.
Updated 19 March 2026
swiftiosmobilepersona
Swift Integration
Use the native Swift SDK when you want the Persona flow directly inside an iOS app without going through React Native or Flutter.
Use the native config surface
The current Swift SDK is config-driven. Set up OnairosConfig, call OnairosSDK.shared.initialize(config:), and create a UIButton with createConnectButton.
1. Add the Swift package
Add the package through Xcode with File → Add Package Dependencies and use:
https://github.com/onairos/onairos-swift-sdk
2. Configure and initialize the SDK
import UIKit
import OnairosSDK
let config = OnairosConfig(
apiKey: "your_api_key",
environment: .production,
googleClientID: "your-google-client-id.apps.googleusercontent.com",
platforms: [.chatgpt, .youtube, .linkedin],
recommendedPlatforms: [.chatgpt, .youtube],
urlScheme: "yourapp",
appName: "YourApp"
)
OnairosSDK.shared.initialize(config: config)
3. Create and add the connect button
let button = OnairosSDK.shared.createConnectButton(text: "Connect your data") { result in
switch result {
case .success(let onboardingResult):
switch onboardingResult {
case .success(let data):
print(data.apiURL)
print(data.token)
print(data.connectedPlatforms.keys)
case .failure(let error):
print(error.localizedDescription)
}
case .failure(let error):
print(error.localizedDescription)
}
}
view.addSubview(button)
Connector customization
platformscontrols which connectors appear on the connection screen.platformspreserves order. The first platform in the array is the default selected connector.recommendedPlatformsadds theHighly Recommendedbadge without changing order.
Main config fields
| Field | Required | What it does |
|---|---|---|
apiKey | Yes | Your developer API key. |
urlScheme | Yes | The custom URL scheme used for OAuth callbacks back into your app. |
appName | Yes | The app name shown inside the consent and onboarding UI. |
platforms | No | The visible connector list in the order you want to present it. |
recommendedPlatforms | No | The connectors that receive the recommendation badge. |
googleClientID | No | Use this when you need YouTube / Google sign-in. |
What success returns
On success the Swift SDK gives you OnboardingData. The most useful fields are:
| Field | Meaning |
|---|---|
apiURL | The returned Persona API URL |
token | Short-lived token for that returned API URL |
userData | User/session data collected in the flow |
connectedPlatforms | The connectors that completed successfully |
inferenceData | Optional extra inference payload when present |
Manual fetch example
var request = URLRequest(url: URL(string: data.apiURL)!)
request.httpMethod = "POST"
request.setValue("Bearer \(data.token)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try JSONSerialization.data(withJSONObject: [
"Input": [
"item1": ["text": "Example content", "category": "general"]
]
])
URLSession.shared.dataTask(with: request) { responseData, _, error in
if let responseData = responseData {
print(String(decoding: responseData, as: UTF8.self))
}
}.resume()
Next step
Use Inference API if your Swift app will call the returned route itself.