Documentation menu

Purpl Documentation

Entitlements and restoration

Check current access and restore App Store purchases.

Check entitlements

Swift
let customerInfo = try await Purchases.shared.customerInfo()

if customerInfo.isEntitlementActive("plus") {
    enablePremiumFeatures()
}

In local mode, CustomerInfo matches current StoreKit entitlement transactions to products in PurchaseConfiguration.

Observe entitlement state in SwiftUI

customerInfoTask loads customer information when the view appears and delivers updated CustomerInfo values through the same task after purchases or restoration change access.

SwiftUI
@State private var hasPlusAccess = false

var body: some View {
    ContentView(hasPlusAccess: hasPlusAccess)
        .customerInfoTask(for: nil) { state in
            guard case .success(let customerInfo) = state else {
                return
            }

            hasPlusAccess = customerInfo.isEntitlementActive("plus")
        }
}

Restore purchases

Swift
let customerInfo = try await Purchases.shared.restorePurchases()