Decode and read App Store receipt data.
import TPInAppReceipt
// Local receipt
let receipt = try await AppReceipt.local
// From raw data
let receipt = try AppReceipt.receipt(from: data)AppReceipt is a typealias over ContentInfo<SignedData<InAppReceiptPayload>> — the full PKCS#7 structure is accessible.
receipt.bundleIdentifier
receipt.appVersion
receipt.originalAppVersion // String?
receipt.environment // .production, .sandbox, .xcode, .productionSandbox
receipt.creationDate
receipt.expirationDate // VPP onlySee doc:Receipt-Fields for the full list of fields.
receipt.purchases // [InAppPurchase]
receipt.hasPurchases
receipt.autoRenewablePurchases
receipt.activeAutoRenewableSubscriptionPurchasesQuery by product:
receipt.purchases(ofProductIdentifier: "com.example.sub")
receipt.containsPurchase(ofProductIdentifier: "com.example.premium")
receipt.hasActiveAutoRenewableSubscription(
ofProductIdentifier: "com.example.sub",
forDate: Date()
)
receipt.lastAutoRenewableSubscriptionPurchase(
ofProductIdentifier: "com.example.sub"
)Pass product identifiers within the same subscription group:
receipt.isEligibleForIntroductoryOffer(
for: ["com.example.bronze", "com.example.silver", "com.example.gold"]
)Request an updated receipt from the App Store:
try await AppReceipt.refresh()