[ad_1]
A toot by my buddy Casey introduced again some irritating recollections about expired subscriptions that haven’t expired (sure, actually). This weblog publish will hopefully provide help to keep away from having these similar recollections.
All of it begins when a buyer contacts you with a screenshot that appears one thing like this:
Your code and the App Retailer don’t agree about when a subscription expired. The reason for that is Apple’s StoreKit pattern code. It’s possible that you’ve some code much like line 246 of Retailer.swift
:
subscriptionGroupStatus = attempt? await subscriptions.first?.subscription?.standing.first?.state
That code will work high-quality till you encounter a buyer that has Household Sharing enabled, as most do. The difficulty is that the Product.SubscriptionInfo can include a number of objects, and the code above solely checks the primary one.
How can that occur? With Household Sharing, the people who find themselves utilizing the subscription act independently: one could subscribe for a yr after which cancel. Then one other may subscribe at a later date for under a month. It’s important to examine the entire subscriptions, not simply the primary one. One thing like this:
if let statuses = attempt? await subscriptions.first?.subscription?.standing { let checkStatus = statuses.first $0.state == .inGracePeriod ... }
The documentation and pattern code doesn’t say it, so I’ll: Apple’s StoreKit pattern doesn’t help Household Sharing.
In case you’re on the lookout for code from Apple that does help Household Sharing, you’ll find it buried in one of many WWDC demo apps. Clearly.
What’s most irritating about this case is that you understand it exists when you’ve learn the documentation:
The array can have a couple of subscription standing in case your subscription helps Household Sharing. Present the shopper with service for the subscription primarily based on the best degree of service the place the state is subscribed.
Which is not sensible till you’ve learn the paragraphs above.
Truly, I used to be mistaken. Essentially the most irritating factor about this case is that it’s basically untestable. You’ll be able to’t reproduce the issue, even after a buyer lets you understand they’re having points and also you’ve learn this weblog publish. That’s as a result of there may be:
- No option to take a look at this in Xcode (even when it’s turned on in .storekit configuration).
- No option to take a look at this in TestFlight (faux purchases don’t use Household Sharing).
- No cheap option to take a look at this in manufacturing (crimson flags shall be raised with refunding and altering purchases repeatedly whereas testing with actual Apple IDs).
The StoreKit take a look at harness in Xcode has been a godsend, however on this case it’s simply less than the duty. And the result’s plenty of annoyed builders who’re testing code in manufacturing on a buyer’s machine.
Apple of us: you’ll be able to be taught extra in FB13212468. It’s been closed as “Investigation full” — possibly it is best to ask Casey if he agrees with that decision.
[ad_2]
Source link