4

First off, this question pertains to iOS7+ receipts so all the questions/answers on SO which refer to latest_receipt and latest_receipt_info are not applicable (as they have been deprecated and are going away). It seems that the bulk of the knowledge base about renewing subscriptions on SO is from 2011 and 2012 so is misleading and providing incorrect information for current specs.

I know when my user's current subscription expires. I want to know if they renewed it or not. According to Apple when their subscription is renewed:

After a subscription is successfully renewed, Store Kit adds a transaction for the renewal to the transaction queue. Your app checks the transaction queue on launch and handles the renewal the same way as any other transaction. Note that if your app is already running when the subscription renews, the transaction observer is not called; your app finds out about the renewal the next time it’s launched.

That all makes sense. So now the obvious question, which Apple does not address, is how do I determine if the subscription was renewed if the user does not close the app and relaunch it (which causes StoreKit to send the app the transaction to process)? If the user leaves the app open for a long period of time the transaction will not be received but I can't continue to provide the content because the expiration date has passed. In theory a user could leave the app running for months without relaunching.

Is the answer to call [NSBundle mainBundle].appStoreReceiptURL to get the receipt myself and then validate it? Will this provide the updated receipt? And then when the transaction arrives from the StoreKit queue on next launch just process that same receipt a second time (since there is no real way to ignore it)? This seems very kludgy. If we have to get the receipt ourselves in some cases, why bother sending it to us via the queue at all?

Any thoughts on the correct workflow?

4
  • This is pretty much what I did. I set up a timer (10 minutes in dev, 12 hours in production) that triggers a subscription check. It scans through the active subscriptions looking for any that have expired. If any have expired then it uses [NSBundle mainBundle].appStoreReceiptURL to refresh the active subscriptions.
    – Paulw11
    Jun 7, 2016 at 1:32
  • That's what I was thinking, but that makes Apple's renewal notification system completely useless and more annoying than helpful. I feel like I'm missing something as nowhere does Apple recommend doing that.
    – Joel
    Jun 7, 2016 at 1:41
  • I guess they were thinking about subscriptions like a magazine app where people will be in and out of apps. In my case I am using the subscription for an enterprise app that will typically be used on a dedicated iPad, so like your case, there is a good chance the device will run the same app for a long time. I honestly don't see it as such a big deal though. It took about 5 minutes to code.
    – Paulw11
    Jun 7, 2016 at 1:44
  • It's not the coding complexity that concerns me. It's that Apple says do one thing but the solution is to do something else, hence the concern that I'm missing something.
    – Joel
    Jun 7, 2016 at 1:46

1 Answer 1

1

If you verify the device's onboard receipt using Apple's verification URL, the JSON response will contain at key 'latest_receipt_info' an array representing an up-to-date list of transactions for this Apple ID. This list will include any renewals that have taken place since the last time the StoreKit transaction queue was updated. I.e. you can do this at any time, either from the device or from your server, to find out about any renewal/s, and you only need to watch the transaction queue to find out about the user's initial purchase of the subscription.

This SO answer is very helpful concerning the ambiguous language in Apple's docs that seems to have left so many of us confused: https://stackoverflow.com/a/35912565/492075

1
  • Interesting. So perhaps those fields aren't deprecated after all, and it's just sloppy documentation. Thanks for pointing that out.
    – Joel
    Jul 31, 2016 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.