Restoring in auto-renewing subscriptions

Hi guys, i’ve just read the tutorial and have a question about restoring state. So if user taps on restore button, we call SKPaymentQueue.default().restoreCompletedTransactions() and paymentQueue(_ queue: SKPaymentQueue,
** updatedTransactions transactions: [SKPaymentTransaction])** in AppDelegate will be called for each transaction. in the implementation in the tutorial, SubscriptionService.shared.uploadReceipt() is called for each transaction. While testing i found out that this method will be called for each subscription period, so if user is subscribed for 11 months, and restores subscription, then handleRestoredState(for transaction: SKPaymentTransaction, in queue: SKPaymentQueue) will be called for 11 times, and it will upload receipt to app store for 11 times. In my solution, i’m collecting all transactions with restore state into one array, and calling the handleRestoredState(for transaction: [SKPaymentTransaction], in queue: SKPaymentQueue) i.e passing array to it. So is it good to do like this ?

Second one, in the tutorial, as i think, there’s no checking for subscription expire date for restore case, i.e if user has a expired subscription, he can tap restore and get access to premium data. Shouldn’t there be checking for expire date also ?

@cwagdev Can you please help with this when you get a chance? Thank you - much appreciated! :]

Sounds like a more efficient solution to collect each item in an array and send it off in one call.

Yes, you should be guarding against the expiration date to protect your content/features. In App Purchases all come down to a tradeoff. How much development time is it worth spending to protect against boundary cases where a user might have access to something they’ve stopped paying for? If it costs you actual resources to provide that content (say a streaming service) then it will probably be worth the development time to make sure their access stops as soon as the subscription expires. If it’s unlocking a certain client side feature, it may not be that big of a deal if they have access for a little while beyond their subscription period. Then of course the entire situation changes based on your scale, if you have hundreds of users, you won’t be leaking much potential revenue, if you have millions… it will very likely be worth your while to tighten it up as much as possible.

You’ll have to decide what is best for your business.

This topic was automatically closed after 166 days. New replies are no longer allowed.