Getting Started

You can add the Link SDK to 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:

  1. Go to File > Add Package Dependencies.
  2. Enter the Anon package URL in the search bar: https://github.com/anon-dot-com/sdk-ios-pkg
  3. Choose the sdk-ios-pkg package.
  4. Select the AnonKit package product and click Add Package.

You can proceed to initialize the AnonKit Link SDK. This step is critical to starting your application’s interaction with the SDK.

Here’s an example of using the Link 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(
        environment: .sandbox,
        // Your SDK Client ID
        // See the Link SDK Getting Started guide to create one
        clientId: "your-client-id-here",
        // This ID token comes from your login process
        // with Auth providers like AWS Cognito, Auth0, etc
        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!")
            }
            .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!


Check out our supported Integrations below.