I'm currently hooking up StoreKit2 to my app. I worked my way through an older example that listened to products and added/removed ids as they came up. This example fell short using the StoreKit config file as all subscriptions don't have a revocation date set so my list of purchased ids just grew longer (as they weren't removed).
My app is only using a single subscription group and thus will only have one subscription live at once. I'm currently grabbing the current subscription using for await result in Transaction.currentEntitlements
and am showing the subscriptions with StoreView(ids: arrayIds)
and SubscriptionStoreView(groupID: subscriptionGroupID)
depending where they user is. Currently when those views disappear I grab the current subscription again (thus updating it if it was changed). That seems cumbersome especially if it doesn't need to be updated and I'm not getting the following error: Making a purchase without listening for transaction updates risks missing successful purchases. Create a Task to iterate Transaction.updates at launch.
.
I'm wondering if there's a way to just listen to the StoreKit Subscription ID in my main App entry point thus making the final error disappear and maybe, if I could update the type of subscription, removing my onDisappear
subscription fetches throughout the rest of the app.
All the examples I come across seem to be either tied up with SwiftData (WWDC 2023) or older and maybe not applicable anymore. Everything seems to be embedded in StoreKit and it would be lovely if I could listen in one simple spot for in app and outside app subscription changes.
Thanks :)