Autorenewable subscriptions renewing after expiry date in sandbox

I'm testing autorenewable subscriptions and wanted to understand the logic behind renewals as the sandbox behaviour seems to act differently to the documentation in terms of renewing before the expiration date.


According to the documentation...


During the 24-hour period before the subscription expires, the App Store starts trying to automatically renew it. The App Store makes several attempts to automatically renew the subscription over a period of time but eventually stops if there are too many failed attempts.


I run a script that determines if a subscription has expired by sending the iap receipt to apple and checking the response to see if there is a new iap with an expiry date in the future. If there is not and the current expiry date is before the time I'm running the script I take it as an expired subscription as I am assuming it would have been updated in the previous 24 hours (or shortly before in sandbox env).


On the sandbox I'm seeing behaviour where the subscription can be renewed after the expiry date - I mark it as expired and then in a future run there is a renewal in the response.


E.g. A subscription has an expiration date of "2017-02-08T15:32:41Z" so I would expect apple to show a renewal before this time. However it doesn't so I mark as expired. On the next run of the script a renewal appears with an expiration date of "2017-02-08T15:39:55Z" which is over 7 minutes after the previous expiration date, which shows that the renewal occurred 2 minutes after the previous expiration date. There's many examples of this happening.


My question is how should I account for this behaviour in production? Does it happen? Should I be acting as though the subscription has expired, seeing as the expiration date has passed? Or should I allow an extra day? According to the documentation I should be fine assuming that the subscription renewal happens in the previous 24 hours prior to expiration but the behaviour here says otherwise.

The renewal will occur before expiration if the user has opened an observer. Alternatively, when the user moves their app into foreground and the app detects an expired subscription it can activate an observer. Note: you seem to be relying on sending an old receipt and getting a latest_receipt_info field. That is not documented and may fail. The only documentation for relying on this method comes from postings on this forum by Rich. Hopefully Apple will respect those postings and not screw you.

Thank you PBK,


Yes I've been following the discussions on here. In future I will switch to the in_app array and look for the latest expiry date which seems to be a more future proof method, although I have read that this is unreliable in itself.


I found this in the documentation after I posted the question so it seems it can renew after the previous subscription expires.


Because of the accelerated expiration and renewal rate, the subscription can expire before the system starts trying to renew the subscription, leaving a small lapse in the subscription period. Such lapses are also possible in production for a variety of reasons—make sure your app handles them correctly.

Or perhaps sandbox was replicating a situation where the subscription lapsed e.g due to a payment issue and then renewed shortly after the expiry.


I will add an observer and sync the info in the new receipt with my server to be safe in case it renews after expiration and I've already marked it expired server side.

Autorenewable subscriptions renewing after expiry date in sandbox
 
 
Q