iOS SDK
iOS 15+, StoreKit 2, Swift Package. Download from the dashboard (API keys & SDK) and add it with File → Add Package Dependencies → Add Local.
Configure
import AppwindPurchases
@main struct MyApp: App {
init() {
Purchases.configure(apiKey: "appl_…",
server: URL(string: "https://pay-api.appwind.ai")!,
fallbackServers: [URL(string: "https://pay-api2.appwind.ai")!]) // optional
}
}
Configure once, as early as possible: purchases that finished while the app was closed are picked up at launch.
Identity
Users start anonymous ($anon:…). After your own sign-in:
let (info, created) = try await Purchases.shared.logIn("user_42") // anonymous purchases move to user_42
try await Purchases.shared.logOut() // back to a new anonymous user
Use a stable ID from your backend — never an email that can change.
Access
let info = try await Purchases.shared.customerInfo()
if info.entitlements["pro"]?.isActive == true { … }
for await info in Purchases.shared.customerInfoStream { refreshUI(info) } // renewals, refunds, other devices
customerInfo() is cached for 5 minutes; pass fetchPolicy: .fetchCurrent after something important.
Buy and restore
let offerings = try await Purchases.shared.offerings()
let result = try await Purchases.shared.purchase(package: offerings.current!.annual!)
if result.userCancelled { return }
if result.pending { showAskToBuyNotice() } // Ask to Buy / SCA: access comes when approved
try await Purchases.shared.restorePurchases()
Paywalls
PaywallView() // current offering's paywall
PaywallView(offering: offerings["summer"], customVariables: ["name": user.firstName])
ContentView().presentPaywallIfNeeded(entitlement: "pro")
MyScreen().paywallFooter() // plans + button over your own screen
More
promotionalOffer(product:offerID:)— signed promotional / win-back offersshowManageSubscriptions(),beginRefundRequest(forProduct:)CustomerCenterView()— manage, cancel, refund requests, supportsetAttributes([...]),setEmail(_:)— used in targeting, webhooks and searchFlowView(placement: "onboarding")— the onboarding flow from the dashboardwebCheckoutURL(productID:)— Stripe checkout for the same user
Without our server
If Appwind Pay can't be reached, access is worked out from the device's verified StoreKit purchases; purchases are queued and re-sent until confirmed; the last offerings and paywall stay on the device; fallbackServers are tried in order. Nothing in the app waits on our server to unlock what a customer paid for.