iOS API reference
Every export is fully typed. The signatures and props below come from the package's own reference documentation, so what is listed here is what the installed version ships.
Components
SignIn
component
The SignIn component renders a full app-native sign-in form. It drives the Flow Execution API loop automatically: initiating the flow, presenting the server-defined inputs and actions on each step, and completing when the user is authenticated. SignIn requires .thunderIDProvider(config:) in its ancestor view hierarchy.
Parameters
| Name | Type | Description |
|---|---|---|
| applicationId (required) | String | The Application ID from your Choreo Identity & Access Management application settings. Identifies which sign-in flow to execute. |
| onComplete (optional) | (() -> Void)? | Called when authentication completes successfully. |
| onError (optional) | ((String) -> Void)? | Called with an error message when a flow step fails. |
import SwiftUI
import ThunderIDSwiftUI
struct AuthView: View {
var body: some View {
SignIn(applicationId: "<your-application-id>")
.padding()
}
}
SignInButton
component
The SignInButton component renders a pre-styled button that you can use to trigger your sign-in flow. It reads loading state from ThunderIDState and disables itself automatically while an operation is in progress. SignInButton requires .thunderIDProvider(config:) in its ancestor view hierarchy.
Parameters
| Name | Type | Description |
|---|---|---|
| onTap (optional) | (() -> Void)? | Called when the button is tapped. Use this to present a sign-in sheet or navigate to an auth view. |
import SwiftUI
import ThunderIDSwiftUI
struct LandingView: View {
var body: some View {
SignInButton()
}
}
SignOutButton
component
The SignOutButton component renders a pre-styled button that calls ThunderIDClient.signOut(), then calls ThunderIDState.refresh() to update the reactive auth state. It disables itself automatically while the sign-out operation is in progress. SignOutButton requires .thunderIDProvider(config:) in its ancestor view hierarchy.
Parameters
| Name | Type | Description |
|---|---|---|
| onSignOutComplete (optional) | (() -> Void)? | Called after sign-out completes and ThunderIDState has been refreshed. |
import SwiftUI
import ThunderIDSwiftUI
struct HomeView: View {
var body: some View {
VStack {
Text("You are signed in.")
SignOutButton()
}
}
}
SignUp
component
The SignUp component renders a full app-native registration form. It drives the Flow Execution API registration loop automatically: initiating the flow, presenting the server-defined inputs and actions on each step, and completing when the user is registered and authenticated. SignUp requires .thunderIDProvider(config:) in its ancestor view hierarchy.
Parameters
| Name | Type | Description |
|---|---|---|
| applicationId (required) | String | The Application ID from your Choreo Identity & Access Management application settings. Identifies which registration flow to execute. |
| onComplete (optional) | (() -> Void)? | Called when registration completes successfully. |
| onError (optional) | ((String) -> Void)? | Called with an error message when a flow step fails. |
import SwiftUI
import ThunderIDSwiftUI
struct AuthView: View {
@State private var showSignUp = false
var body: some View {
if showSignUp {
SignUp(applicationId: "<your-application-id>")
.padding()
} else {
SignIn(applicationId: "<your-application-id>")
.padding()
}
}
}
SignedIn
component
The SignedIn component conditionally renders its content only when the user is authenticated. It reads the current sign-in state from ThunderIDState and displays protected UI for signed-in users, while rendering optional fallback content (or nothing) when the user is not authenticated. SignedIn requires .thunderIDProvider(config:) in its ancestor view hierarchy.
Parameters
| Name | Type | Description |
|---|---|---|
| content (required) | @ViewBuilder () -> Content | The view to render when the user is authenticated. |
| fallback (optional) | @ViewBuilder () -> Fallback | The view to render when the user is not authenticated. Defaults to EmptyView. |
import SwiftUI
import ThunderIDSwiftUI
struct ContentView: View {
var body: some View {
SignedIn {
Text("You are signed in.")
}
}
}
SignedOut
component
The SignedOut component conditionally renders its content only when the user is not authenticated. It reads the current sign-in state from ThunderIDState and displays content for unauthenticated users, while rendering optional fallback content (or nothing) when the user is signed in. SignedOut requires .thunderIDProvider(config:) in its ancestor view hierarchy.
Parameters
| Name | Type | Description |
|---|---|---|
| content (required) | @ViewBuilder () -> Content | The view to render when the user is not authenticated. |
| fallback (optional) | @ViewBuilder () -> Fallback | The view to render when the user is authenticated. Defaults to EmptyView. |
import SwiftUI
import ThunderIDSwiftUI
struct ContentView: View {
var body: some View {
SignedOut {
Text("Please sign in to continue.")
}
}
}
UserProfile
component
The UserProfile component renders an editable profile form. It loads the user's current profile from /scim2/Me when it appears, presents editable fields for displayName and phoneNumbers, and saves changes via ThunderIDClient.updateUserProfile. UserProfile requires .thunderIDProvider(config:) in its ancestor view hierarchy.
Parameters
| Name | Type | Description |
|---|---|---|
| onSaved (optional) | (() -> Void)? | Called after a successful profile save. |
| onError (optional) | (() -> Void)? | Called when a load or save operation fails. |
import SwiftUI
import ThunderIDSwiftUI
struct ProfileSheet: View {
@Environment(\.dismiss) var dismiss
var body: some View {
UserProfile {
dismiss()
}
.padding()
}
}
ChangeCredential
component
The ChangeCredential view lets a signed-in user set a new value for one of their own credentials. It validates against the user type schema (GET /users/me/meta) and posts the change via ThunderIDClient.updateUserCredentials. Defaults to password; set attribute for another credential, such as a PIN. Requires .thunderIDProvider(config:) in the view hierarchy. Collects only a new value and its confirmation, not the current one, since the write path doesn't verify it today.
Parameters
| Name | Type | Description |
|---|---|---|
| attribute (optional) | String | The credential attribute this instance manages, any attribute the user type schema declares credential: true for. Defaults to "password". |
| onSuccess (optional) | (() -> Void)? | Called after the credential has been changed successfully. |
import SwiftUI
import ThunderIDSwiftUI
struct SecuritySection: View {
var body: some View {
VStack(alignment: .leading) {
Text("Security")
ChangeCredential()
}
}
}
Functions
Configuration
function
ThunderIDConfig is the configuration struct passed to ThunderIDClient.initialize(config:storage:) and to the .thunderIDProvider(config:) view modifier.
Parameters
| Name | Type | Description |
|---|---|---|
| baseUrl | String | Required. Your Choreo Identity & Access Management instance URL. Must use HTTPS (e.g., https://<DATA_PLANE_URL>). |
| clientId | String? | The Client ID from your Choreo Identity & Access Management application. Required for redirect-based authentication and token operations. |
| scopes | [String] | OAuth 2.0 scopes to request. Include "profile" and "email" to receive user identity claims. |
| afterSignInUrl | String? | The redirect URI to return to after sign-in. Must match an Allowed Redirect URI registered in the console. |
| afterSignOutUrl | String? | The redirect URI to return to after sign-out. Must match an Allowed Post-Logout Redirect URI in the console. |
| signInUrl | String? | Override the sign-in URL. Defaults to the Choreo Identity & Access Management hosted sign-in page. |
| signUpUrl | String? | Override the sign-up URL. |
| clientSecret | String? | Client secret for confidential clients. Do not include this in a shipped iOS app. |
| signInOptions | [String: Any] | Additional query parameters appended to the authorization URL on sign-in. |
| signOutOptions | [String: Any] | Additional parameters sent with the sign-out request. |
| signUpOptions | [String: Any] | Additional parameters sent with the sign-up request. |
| applicationId | String? | The Application ID used for app-native (embedded) sign-in flows via the Flow Execution API. |
| organizationHandle | String? | The organization handle for multi-tenant deployments. |
| tokenValidation | TokenValidationConfig | Controls ID token validation behavior. |
| storage | StorageAdapter? | Custom token storage backend. Defaults to KeychainStorageAdapter. |
| instanceId | Int? | Identifies the SDK instance when running multiple instances in one process. |
import ThunderID
let config = ThunderIDConfig(
baseUrl: "https://<DATA_PLANE_URL>",
clientId: "<your-client-id>",
scopes: ["openid", "profile", "email"],
afterSignInUrl: "io.thunderid.b2c://callback",
afterSignOutUrl: "io.thunderid.b2c://logout",
applicationId: "<your-application-id>"
)
ThunderIDClient
function
ThunderIDClient is the core authentication client in the ThunderID package. It manages the full authentication lifecycle: initialization, sign-in (both app-native and redirect-based), session, token management, and user profile operations. When you use the ThunderIDSwiftUI package, a ThunderIDClient instance is created and managed automatically. You can access it via ThunderIDState.client from any view.
import ThunderID
let client = ThunderIDClient()
try await client.initialize(config: ThunderIDConfig(
baseUrl: "https://<DATA_PLANE_URL>",
clientId: "<your-client-id>",
scopes: ["openid", "profile", "email"],
afterSignInUrl: "io.thunderid.b2c://callback",
afterSignOutUrl: "io.thunderid.b2c://logout"
))
ThunderIDState
function
ThunderIDState is the reactive authentication state object provided by the ThunderIDSwiftUI package. It is an ObservableObject that holds the current user, loading state, and initialization status, and exposes the underlying ThunderIDClient for direct API calls. ThunderIDState is injected into the SwiftUI environment by the .thunderIDProvider(config:) modifier. Any view in the hierarchy can read it using @EnvironmentObject.
import SwiftUI
import ThunderIDSwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.thunderIDProvider(config: ThunderIDConfig(
baseUrl: "https://<DATA_PLANE_URL>",
clientId: "<your-client-id>",
afterSignInUrl: "io.thunderid.b2c://callback",
afterSignOutUrl: "io.thunderid.b2c://logout"
))
}
}
}
Was this page helpful?