Skip to main content

Quickstart

Get AppActor running in your app in three steps.

Step 1: Install the SDKโ€‹

// In Xcode: File > Add Package Dependencies
// Enter the repository URL:
// https://github.com/appactor/appactor-ios.git

// Or in Package.swift:
dependencies: [
.package(url: "https://github.com/appactor/appactor-ios.git", from: "1.0.0")
]

Step 2: Configure the SDKโ€‹

Initialize AppActor when your app launches. You only need your API key from the AppActor dashboard.

import AppActor

@main
struct MyApp: App {
init() {
AppActor.configure(apiKey: "pk_live_your_key_here")
}

var body: some Scene {
WindowGroup {
ContentView()
}
}
}

Step 3: Make a Purchaseโ€‹

Fetch offerings, display products, and handle purchases.

// Wait for bootstrap if you need guaranteed initial data
await AppActor.shared.awaitBootstrap()

// Fetch server-driven offerings
let offerings = try await AppActor.shared.offerings()
guard let package = offerings.current?.monthly else { return }

// Display price
Text(package.localizedPrice) // e.g. "$9.99/month"

// Make a purchase
let result = try await AppActor.shared.purchase(package: package)

switch result {
case .success(let customerInfo):
if customerInfo?.hasActiveEntitlement("premium") == true {
// Unlock premium features
}
case .pendingServerValidation:
// Receipt is queued and will retry automatically
// You can call syncPurchases() manually if needed
case .cancelled:
break // User cancelled
case .pending:
break // Pending (Ask to Buy, SCA)
case .failedServerValidation(let code, let message, let requestId):
print("Validation failed [\(code ?? "unknown")] requestId=\(requestId ?? "n/a")")
print(message ?? "Receipt could not be validated")
}

Next Stepsโ€‹