UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

StoreKit2 - How to know which subscription the user has properly?

Forums > iOS

I'm currently attempting to hook my app into storekit2 using the testing config file grabbing information from App Store Connect. Right now I can see the renewing subscription choices (all under one one group id so only one can be picked at a time) and can "subscribe" to one and down/upgrade to another. In case you're stuck here I'm doing this through the view: SubscriptionStoreView(groupID: subscriptionGroupID, visibleRelationships: .all) but also implemented it, prior to that handy call, through another tutorial that created a class PurchaseManager that handled everything including physically generating the subscribe buttons.

My issue now is how to know which subscription, or maybe none, the user is subscribed to properly. Right now I want to display different information based on the subscription picked but I have no way to know what they have.

I am currently using a for statement to grab the Transaction.currentEntitlements and realized it always seemed to print the same as the renew period wasn't up. To clear the current purchases you can use the debug buttons: https://developer.apple.com/forums/thread/692574

Right now I find the subscription ID with:

func findSubscriptionPurchased() async -> String? {
        for await result in Transaction.currentEntitlements {
            guard case .verified(let transaction) = result else {
            return transaction.productID
        return nil // No purchased subscription

Is there a better way? Thanks for any help or direction.


Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.