How to test subscriptions through Storekit 2 in Sandbox?

Hey all,

Tl;dr:

In debug-build using a .storekit file, all is good. When uploading a release build to testflight, purchasing follow the expected flow, but it does not seem the subscription status is reflected.

Full description

I've implemented auto-renewable subscriptions in my app. In debug, I've setup a scheme to use products.storekit. When I run this scheme on my device, I can subscrbe, cancel etc, and it all works as expected.

When I upload my release scheme to testflight, purchasing can be done, but changes do not seem to be reflected inside the app (i.e.e no features get unlocked). Same thing when I run this scheme on my device. This scheme has None set for Storekit configuration. When I set 'Storekit configuration' to the Products.storekit, file I can't make a purches at all: SubscriptionStoreView shows

Subscription unavailable. The subscription is unavailable in the current storefront'.

I've watched a number of WWDC sessions on the topic, read most (all?) of the documentation, and I just can't seem to find out what it is that needs to be done. Unfortunately, debugging has been rather cumbersome and sometimes impossible lately, especially when trying to debug a release build.

Anyone can tell me what it is I am overlooking, or what piece of information or link I missed?

Here is the relevant code (which works OK in debug)

private func listenForTransactions() -> Task<Void, Error>
    {
        return Task.detached
        {
            for await anUpdate in Transaction.updates
            {
                do
                {
                    let transaction = try self.checkVerified(anUpdate)
                    
                    await self.checkSubscriptionStatus()
                    
                    await transaction.finish()
                }
            }
        }
    }

And here's checkSubscriptionStatus():

@MainActor
    private func checkSubscriptionStatus() async
    {
        var hasActiveSubscription = false
        do
        {
            for aStatus in try await Product.SubscriptionInfo.status(for: "718A7488")
            {
                let state = aStatus.state
                hasActiveSubscription = (state == .inGracePeriod) || (state == .subscribed)
            }
        }
        catch
        {
            print(error)
        }
        self.hasActiveSubscription = hasActiveSubscription
    }
Post not yet marked as solved Up vote post of Joride Down vote post of Joride
359 views