I am looking to build a ios application that will use an auto-renewable subscription on a yearly biases.My question is, how can we be notified when a user cancels a subscription in IOS, so that we can cancel the users features
-
Essentially a duplicate of http://stackoverflow.com/questions/6302517/notification-of-cancellation-of-auto-renewal-for-an-in-app-purchase – Andrew Mar 06 '13 at 09:18
-
<7b0a0922 7369676e 61747572 6522203d 20224172 4a7a4f50 4a6f5750 61666f30 3168354d 38416150 55485173 384c655a 4b6d6a46 7a383256 704f556b 31534970 6b71784e 78707a39 4e4d6433 4f434271 676c6165 422f2b44 61736e77 43617638 6279466e 78753875 31556d59 57365032 ................> this is my transaction receipt and i have the shared secret like this 42da2ab7bc64..........0db4b5e then how can i request the apple server please give the sample code – MANCHIKANTI KRISHNAKISHORE Mar 06 '13 at 10:12
-
How can i get the response from the apple server – MANCHIKANTI KRISHNAKISHORE Mar 06 '13 at 10:20
2 Answers
sorry if I'm duplicating the reply:
if the receipt status is 21006
and there is a key named cancellation_date
, then it's a cancellation, you can find the new expiration date in that key but it's a formatted date, if you need a better value to parse check for receipt['latest_expired_receipt_info']['cancellation_date_ms']
same as expires_date
do someone known how to be notified by apple without sending verify requests? it would be reasonable to check only when the product is expiring instead to querying each times for all products because of possible cancellation

- 4,890
- 2
- 34
- 50
First things first. If you're app is not a periodical like a magazine, then you should steer away from ARS (auto-renewable subscriptions). Apple may reject it and insist you use NRS (non-renewing subscriptions).
It's more code than I can practically paste in here, but please follow this guide from Apple on Verifying In-App Purchase Receipts.
Basically you'll be putting the receipt and your secret in a JSON object and sending it to Apple. It's preferable to do this from your server and not from the app. Here is a good guide on Verifying Store Receipts Using PHP and cURL
The JSON object will look something like this:
{
"receipt-data" : "(receipt bytes here)",
"password" : "(shared secret bytes here)"
}
Apple will respond with another JSON object that has info such as expiration date.

- 8,363
- 8
- 43
- 71
-
Thanks Andrew, for giving the reply for me . Here i have not any server i am saving this in my plist database . Is receipt-data for an particular product id is constat or it will be change – MANCHIKANTI KRISHNAKISHORE Mar 06 '13 at 10:38
-
1Each time a subscription renews a new receipt will be generated which will be different from the original receipt. So, no, the receipt data is not constant for a given product ID. Also if you use `restoreCompletedTransactions` to extend a subscription to a user's new device, new receipts will be generated that reference the same subscription time period. It can become a dizzying array of receipts. – Andrew Mar 06 '13 at 10:51
-
Actually at first time i subscribed and i got the receipt-data and that receipt-data is stored in plist after one year the same receipt will sent to the apple server . second year same receipt data will send to the apple server or it will be changed – MANCHIKANTI KRISHNAKISHORE Mar 06 '13 at 11:12
-
i am doing this on auto renewable subscription .If suppose user dont cancel his subscription he will be charged again in this process how he will be charged through our app or directly he will be charged from the user credit card – MANCHIKANTI KRISHNAKISHORE Mar 06 '13 at 11:42
-
He will be charged directly from his credit card automatically by Apple at the end of each subscription period. As for your previous comment, you can simply store the original receipt and just send that to Apple each time for verification. For ARS Apple will always respond with the latest receipt for that product ID. So you don't necessarily have to store the new receipts. – Andrew Mar 06 '13 at 19:31
-
1Great. If you could select my answer as the correct one I would greatly appreciate it. – Andrew Mar 08 '13 at 05:11
-
Andrew a small doubt in my app there is no user login so how can i store the transaction receipt on my online server.if suppose 10 users subscribe my app all the 10 transaction receipts are stored in my online sql server how can i differentiate that this particular transaction receipt belongs to user . – MANCHIKANTI KRISHNAKISHORE Jul 04 '13 at 07:05
-
1When saving receipts on your server that you received from the app, you should store a unique ID along with it that identifies that device. I assume you already have a way to differentiate individual devices? The way I do it is, when the user first launches the app I create a unique ID and store it on the device. Whenever there's a request to the server, the Unique ID is sent along with it to identify the device. – Andrew Jul 06 '13 at 19:15
-
You're welcome @MANCHIKANTIKRISHNAKISHORE . Could you select my answer as the correct one by clicking the check mark? – Andrew Jul 10 '13 at 07:27
-
has anyone ever gotten erroneous receipts that have the expiration_date be before the purchase_date? I've got this testing in sandbox mode. – MiMo Jul 16 '14 at 22:31
-
@MiMo I haven't seen that but it wouldn't surprised me since the testing mode is a bit clunky. – Andrew Jul 20 '14 at 17:54