// Apple-only learning file: iOS 17+ target with a suitable Xcode SDK. // Not compiled or run in this Windows/Linux review. import SwiftUI import StoreKit struct DemoView: View { @State private var notice = "No entitlement check" var body: some View { VStack(spacing: 20) { Button("Restore and inspect sandbox entitlements") { Task { do { try await AppStore.sync() var entitled = false for await result in StoreKit.Transaction.currentEntitlements { switch result { case let .verified(transaction): if transaction.productID == "com.example.workshop.demo", transaction.revocationDate == nil { entitled = true } case .unverified: continue } } notice = entitled ? "Verified configured demo entitlement" : "No verified demo entitlement" } catch { notice = "Restore/check failed" } } } Text(notice) Text("No purchase is initiated by this source.").font(.caption) }.padding() } } @main struct WorkshopDemoApp: App { var body: some Scene { WindowGroup { DemoView() } } }