Monday, April 1, 2024

App Store Subscriptions and Family Sharing

Craig Hockenberry:

Your code and the App Store don’t agree about when a subscription expired. The cause of this is Apple’s StoreKit sample code. It’s likely that you have some code similar to line 246 of Store.swift:

subscriptionGroupStatus = try? await subscriptions.first?.subscription?.status.first?.state

That code will work fine until you encounter a customer that has Family Sharing enabled, as most do. The issue is that the Product.SubscriptionInfo can contain multiple items, and the code above only checks the first one.

How can that happen? With Family Sharing, the people who are using the subscription act independently: one may subscribe for a year and then cancel. Then another could subscribe at a later date for only a month. You have to check all of the subscriptions, not just the first one.

As he notes, it’s not documented that the sample code doesn’t support Family Sharing. And, even if you’re aware of this issue, there’s no reasonable way to test your code in Xcode, TestFlight, or even production.

Previously:

Comments RSS · Twitter · Mastodon

Leave a Comment