iOS SDK

Coming Soon Swift / SwiftUI iOS 15+

Coming Soon — The iOS SDK is under development. In the meantime, you can use SFSafariViewController with the verification URL or ASWebAuthenticationSession.

The iOS SDK (Xident) will provide a native Swift-first experience for embedding age verification in iOS and iPadOS apps. It uses ASWebAuthenticationSession for the verification flow and universal links for the callback.

Installation

Swift Package Manager

// Package.swift
dependencies: [
    .package(url: "https://github.com/xident/xident-swift", from: "1.0.0")
]

CocoaPods

# Podfile
pod 'Xident', '~> 1.0'

SwiftUI Example

import SwiftUI
import Xident

struct VerifyButton: View {
    let userId: String

    @State private var isVerifying = false

    private let xident = XidentClient(
        apiKey: "pk_live_your_api_key",
        callbackURL: URL(string: "yourapp://verified")!
    )

    var body: some View {
        Button("Verify Your Age") {
            xident.start(
                userId: userId,
                metadata: ["plan": "premium"]
            )
        }
    }
}

UIKit Example

import UIKit
import Xident

class VerifyViewController: UIViewController {
    let xident = XidentClient(
        apiKey: "pk_live_your_api_key",
        callbackURL: URL(string: "yourapp://verified")!
    )

    @IBAction func verifyTapped(_ sender: UIButton) {
        xident.start(
            from: self,
            userId: "user-123",
            metadata: ["plan": "premium"]
        )
    }
}

Callback Handling

Register a URL scheme or universal link to receive the verification callback:

// AppDelegate.swift or SceneDelegate.swift
func application(_ app: UIApplication,
                 open url: URL,
                 options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
    // Handle: yourapp://verified?token=tok_xxx&status=success
    guard url.scheme == "yourapp", url.host == "verified" else { return false }

    let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
    let token = components?.queryItems?.first(where: { $0.name == "token" })?.value
    let status = components?.queryItems?.first(where: { $0.name == "status" })?.value

    if status == "success", let token = token {
        // Send token to your backend for server-side verification
        verifyTokenOnBackend(token)
    }

    return true
}

Universal Links (Recommended)

// Associated Domains (Xcode)
// 1. Enable "Associated Domains" capability
// 2. Add: applinks:yoursite.com

// apple-app-site-association (on your server)
{
    "applinks": {
        "apps": [],
        "details": [{
            "appID": "TEAM_ID.com.yourapp",
            "paths": ["/verified"]
        }]
    }
}

How It Works

  1. SDK opens ASWebAuthenticationSession to verify.xident.io
  2. User completes verification in the in-app browser
  3. Callback URL returns to your app with yourapp://verified?token=tok_xxx
  4. Your backend verifies the token via the Xident REST API

SFSafariViewController Alternative (Available Now)

While the native SDK is in development, you can use SFSafariViewController:

import SafariServices

func startVerification() {
    let url = URL(string: "https://verify.xident.io?api_key=pk_live_xxx&callback_url=yourapp://verified")!
    let safari = SFSafariViewController(url: url)
    present(safari, animated: true)
}

Requirements

Requirement Minimum
iOS15.0+
Swift5.7+
Xcode14.0+

Related