iOS 15 introduces StoreKit 2. I'm looking at it to see whether I can adopt it in my existing apps, and I don't see how to do it. In particular, I don't see how to implement the required Restore functionality (in case the user has deleted my app, for instance).
I presume we are supposed to use Transaction.latest(for:)
? Is that right?
But in my testing, it appears that if a user has done the purchase with StoreKit 1, that call returns nil
. Is this true? Or if I'm doing it wrong, what's the correct way to migrate from StoreKit 1 to StoreKit 2, and how do we handle Restore?
CodePudding user response:
You can iterate over Transaction.currentEntitlements
in order to obtain all active subscription and previously purchased non-consumable products.
If you check this collection at launch you can silently restore any previous purchases without user interaction.