Platforms
iOS
Embed the account connection flow in your iOS app
Getting Started
You can get started with a SwiftUI example here.
You can embed the account connection flow in your iOS app using the Swift Package Manager (SPM).
To integrate Anon using Swift Package Manager, you’ll need Swift version 5.3 or later. Follow these steps within your Xcode project:
- Go to File > Add Package Dependencies.
- Enter the Anon package URL in the search bar: https://github.com/anon-dot-com/sdk-ios-pkg
- Choose the
sdk-ios-pkg
package. - Select the AnonKit package product and click
Add Package
.
Do the same with the following package: https://github.com/auth0/JWTDecode.swift
Import AnonKit SDK
You can proceed to initialize the AnonKit SDK. This step is critical to starting your application’s interaction with the SDK.
Here’s an example of using the SDK in a modal view using SwiftUI:
import SwiftUI
import AnonKit // Ensure AnonKit SDK is imported
struct ContentView: View {
@State private var isPresenting = false // State to manage SDK presentation
// Configuration for Anon SDK
let anonConfig = AnonKit.Config(
// Change to the appropriate environment as needed.
environment: .sandbox,
// The uuid of your SdkClient /associated with your UserPool/
// ie the one which returned "auth": { "type": "userPool", "userPoolId": "..." }
clientId: "your-client-id-here",
// Your application user ID token, eg the JWT
// May be Anon-provided as the `example_app_user_id_token` from 1pass
appUserIdToken: "your-jwt-id-token-here"
)
var body: some View {
NavigationView {
VStack {
Image(systemName: "message") // Placeholder for app content
.imageScale(.large)
.foregroundColor(.blue)
Text("Welcome to my app, tap to proceed!")
}
.padding()
.onTapGesture {
isPresenting.toggle() // Toggle presentation state
}
}
.fullScreenCover(isPresented: $isPresenting, onDismiss: didDismiss) {
// Present Anon SDK UI
AnonUIView(
// Example app identifier
app: "grubdash",
config: anonConfig,
ui: AnonKit.UIConfig(
organizationName: "My Company",
// Your organization's icon URL
organizationIconUrl: URL(string: "https://example.com/org-logo.png"),
// Theme selection
theme: .dark
)
)
}
}
func didDismiss() {
// Handle the dismissing action here.
print("SDK was dismissed")
}
}
Now you are ready to continue setting up your Integrations!
Next Steps
Was this page helpful?