I'm also seeing this issue so just +1ing the issue.
Also curious if there is a technical reason why promotional offers are not signed/validated automatically by StoreKit2 the same way purchases can now be signed by the framework itself? Thanks
Post
Replies
Boosts
Views
Activity
+1 on this issue and I'm also seeing very erratic behavior on these status changes.
Similarly, shouldn't a change in auto-renew status trigger a change via the subscription info's status updates stream? static var updates: Product.SubscriptionInfo.Status.Statuses { get }
(https://developer.apple.com/documentation/storekit/product/subscriptioninfo/status/3851115-updates)
@eskimo wondered if you could weigh in on this status change for auto-renew? Thanks in advance.
This state miss-match appears to be a result of StoreKit2 cacheing subscription info in a local database at: ../app_container/Library/Caches/StoreKit/receipts.db.
I was able to improve my flow by doing the following after displaying the manage subscriptions sheet.
Clear the caches directory
Fetch either the entitlement via Transaction.currentEntitlements or refresh a specific subscription group via Product.SubscriptionInfo.status(for:).
Example cache clear:
public func clearStoreKitReceiptsCache() throws {
let fileManger = FileManager.default
guard let cachesDir = fileManger.urls(for: .cachesDirectory, in: .userDomainMask).first else { return }
guard let storeKitPath = try fileManger.contentsOfDirectory(
at: cachesDir,
includingPropertiesForKeys: nil,
options: []).first(where: { $0.lastPathComponent == "StoreKit" }) else { return }
try fileManger.removeItem(at: storeKitPath)
}
Subscription status updates will come in via Product.SubscriptionInfo.Status.updates instead of Transaction.updates. Creating a task to observe those updates will help with your issue.
I suspect this too could be related to incorrect cache assumptions made by StoreKit2.
https://developer.apple.com/forums/thread/690890?answerId=705952022#705952022