0

I'm trying to work out the best way to get updated receipt expiration when an iOS auto-renewing subscription renews. I know that what's supposed to happen is that it will be delivered via the SKPaymentQueue transaction observers. However,

  • This only happens when the app launches. My app is vertical market style app that might run for hours or days, so checking at launch isn't enough.
  • Transaction observer delivery doesn't seem to be reliable. In testing I've had subscriptions that should have renewed but where no new info was delivered to the transaction observer even after relaunching.

But of course it's also possible to get updated info on demand by revalidating the receipt with Apple. Given the above two issues, I'm thinking I'll need to run a timer that just periodically

  • Checks if the subscription should renew "soon", i.e. within some TBD period in the future (maybe within the next day).
  • If so, attempts to get updated info from Apple by revalidating the receipt.

How do other people handle this? The timer approach seems ridiculous but I haven't come up with anything better yet.

Tom Harrington
  • 69,312
  • 10
  • 146
  • 170
  • Take a look at http://cocoapods.org/pods/SubscriptionMonitor. I created it as I have an app with a similar functionality to yours; it may run for days or weeks at a time. It uses a timer to periodically refresh the receipt and validate it with Apple via a server. – Paulw11 Dec 12 '16 at 18:43
  • I've got everything working except this part, and I'm hesitant to throw it out and drop in an unknown (to me, no offense) open source project. But you say you've found that an `NSTimer` is the best way to go? – Tom Harrington Dec 12 '16 at 20:33
  • There is no other approach that works for a long-running app. There are no events delivered to your app when the subscription renews if your app is already running. – Paulw11 Dec 12 '16 at 21:07
  • @Paulw11 I know there aren't any other events but I was hoping there was a better way. If you write an answer covering this I'll accept it. – Tom Harrington Dec 13 '16 at 17:36

0 Answers0