I have an app with one subscription to buy. Buying works fine and renewal seems to work fine, too.
I am observing transaction for this IAPin the background. To understand what is happening in the background I add print debug statements and I see that after each renewal two nearly identical transactions exist. This is the function which generates the task to watch for transaction happening in the background:
private func observeTransactionUpdates() -> Task<Void, Never> {
Task(priority: .background) { [unowned self] in
for await verificationResult in Transaction.updates {
await self.updatePurchasedProducts()
if case .verified(let transaction) = verificationResult {
print("Verified")
print(transaction)
await transaction.finish() // Ensure finishing all transactions
} else if case .unverified(let transaction, _) = verificationResult {
print("Unverified")
print(transaction)
await transaction.finish() // Even finish unverified transactions
}
}
}
}
This is the debug output happening all 3 minutes(sandbox) after renewal:
Verified
{
"bundleId" : "...app",
"currency" : "EUR",
"deviceVerification" : "...qZZf",
"deviceVerificationNonce" : "...df9",
"environment" : "Sandbox",
"expiresDate" : 1718878102000,
"inAppOwnershipType" : "PURCHASED",
"originalPurchaseDate" : 1718536890000,
"originalTransactionId" : "...1810",
"price" : 2990,
"productId" : "....premium.monthly",
"purchaseDate" : 1718877922000,
"quantity" : 1,
"signedDate" : 1718877887210,
"storefront" : "DEU",
"storefrontId" : "...443",
"subscriptionGroupIdentifier" : "...060",
"transactionId" : "...5774",
"transactionReason" : "RENEWAL",
"type" : "Auto-Renewable Subscription",
"webOrderLineItemId" : "...9876"
}
Verified
{
"bundleId" : "...app",
"currency" : "EUR",
"deviceVerification" : "...ocx",
"deviceVerificationNonce" : "...3bf",
"environment" : "Sandbox",
"expiresDate" : 1718878102000,
"inAppOwnershipType" : "PURCHASED",
"originalPurchaseDate" : 1718536890000,
"originalTransactionId" : "...1810",
"price" : 2990,
"productId" : "....premium.monthly",
"purchaseDate" : 1718877922000,
"quantity" : 1,
"signedDate" : 1718877888930,
"storefront" : "DEU",
"storefrontId" : "...443",
"subscriptionGroupIdentifier" : "...060",
"transactionId" : "...5774",
"transactionReason" : "RENEWAL",
"type" : "Auto-Renewable Subscription",
"webOrderLineItemId" : "...9876"
}
After a renewal of a purchased product I would expect one transaction with a valid expiration date happening in the background but not two transactions with the same expiration date. Why is that so?