Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Auto Renewable Subscriptions Expiry

Question 1:

I have read the Apple docs regarding subscriptions but I'm still unsure if it's possible to get the expiry date for an auto-renewable subscription from the receipt without contacting Apple servers as of iOS 9? Does this makes sense?

Question 2

Currently what I'm doing to get the auto-renewable subscription expiry is:

  • use [[NSBundle mainBundle] appStoreReceiptURL] and proceed to convert the receipt to a base 64 string

  • create a dictionary where I include this receipt-data and the shared secret

  • convert this dictionary into a JSON string

  • send this JSON string to https://sandbox.itunes.apple.com/verifyReceipt

  • return the JSONized receipt dictionary which was received as a reply from the app store

  • get the expiry date from the expires_date_ms inside the latest_receipt_info dictionary

I'm not entirely sure if this is correct since according to the documentation it's not possible to achieve a secure link between the App Store and a device (which I'm currently doing). In fact the documentation states that I'll need my own server which will communicate with the App Store for me (https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1).

Is this acceptable approach or I'll need my own server? If I need my own server can someone kindly guide me in the right direction on how to set this up?

N.B: I'm performing receipt validation for non-consumable and consumable in-app purchases whenever a purchase is made using local validation using OpenSSL. So that should be allright.

Thanks in advance.

like image 891
Nokiaowner Avatar asked Oct 19 '22 19:10

Nokiaowner


1 Answers

Here are the step to implement Auto- Renewable service in your application.

  1. Whenever your app completed in app purchase. you should send receipt data (In Base 64 Encoding) to your server in which it will store with particular user profile( this is just for example)

2)You need to create cron job on your server.This cron job will run once in a day which is used to verify each and every receipt.

3)In this verification process you simply need to call apple service which you have mention in your question.

  1. In each call you will get response from the apple in which apple will provide all detail of auto renew. If any user gets renew his service then you will find one more object in the response. in which the expiry date is extended.

Hope this will help you.

like image 173
Crazy Developer Avatar answered Oct 22 '22 01:10

Crazy Developer