First all be aware of Apple's policy as for auto renewable subscription and application types that could use it (your app could be rejected if reviewers will decide you that you are missusing subscriptions).
11.15 Apps may only use auto renewing subscriptions for periodicals (newspapers, magazines), business Apps (enterprise, productivity, professional creative, cloud storage) and media Apps (video, audio, voice), or the App will be rejected
Auto renewable subscriptions flow
Basically it works as all AppStore in-app purchases - iOS makes purchase on client side, receives Receipt and gives it server for validation. An issue appears when you need to renew subscription - unfortunately there is no something like IPN in PayPal and AppStore does not "push inform" us about prolongation or cancellation of subscription (as PayPal do). We need to do it ourselves.
As for auto-renew subscriptions we should make such steps:
Read more ...
- Take initial receipt, validate it on server side (what should be validated except Apple response - is a topic for another big post)
- Store initial receipt in DB (assign to user internally and save renew date)
- CRON job should make periodic check of records by renew date (frequency depends on your logic, but once in 1-6 hours could be fine)
- If it is time to check some subscription - take previously saved Receipt and make a validate request to Apple server as usually
- If subscription was continued and money booked from user - you will receive response with new Receipt (and old one also), if not renewed - you will receive "Expired" response.
- If subscription was continued and success response received - save it to DB, and use in next subscription validation round
- If not - process your app logic on expired subscription (close some services for this user or something)