0

I want to offer a renewable subscription in my iOS application. The user subscribed and the receipt is stored. Now i wonder how i need to make sure that the receipt is valid and not cancelled:

  1. If the user cancels the subscription and it is not renewed, how would i know it? If the subscription is renewed, when a new receipt will be created?

  2. If the user cancels the subscription through apple support (because, for example, he bought it my mistake), how can i know it? The receipt on the device will be valid. Should i refresh the receipt every time the user logs in?


EDIT: I forgot to mention it, but the receipt is checked in the client side.

Erik Sapir
  • 23,209
  • 28
  • 81
  • 141

1 Answers1

0

Generally you need to check the expiration date of the subscription. To do that you need to get the receipt list and find the most recent record. It could be done using several ways (iOS Restore in App purchases with receipts)

  1. If user cancels the subscription, I believe it means that receipt list simply will updated and you can find this by reading the 'cancellation date' field. To get track the expiration date I'd recommend to use UILocalNotification. If user continues to use subscription and you doubt whether he prolonged it or not, you should update the receipt list and send request to Apple [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]

  2. If user cancel the subscription through apple support , you can find the corresponding record (aka "Cancellation Date") in the receipt data. Please read (https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html). I'd recommend to check the receipt from time to time or use a notification mechanism.

Community
  • 1
  • 1
David
  • 1,061
  • 11
  • 18
  • Restoring the receipts list will ask the user to enter credentials, no? – Erik Sapir Sep 23 '15 at 17:16
  • Actually yes, as I remember. Otherwise Apple must validate somehow your Apple ID and return the correct receipt list with all your transactions. But when you ask user once, all the user credentials are saved and later you can request for receipt info without bothering user. For a better user experience Apple ask to have a "Restore purchases/subscription" button somewhere in the app interface. – David Sep 23 '15 at 18:12
  • so should i just call restore every time app launches? – Erik Sapir Sep 23 '15 at 18:46
  • No you don't. First of all you should check the existed receipt list that might exist on user device. `NSURL *URL = [[NSBundle mainBundle] appStoreReceiptURL]; NSString *path = URL.path; BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:nil];` It should be there whenever user makes a payment or you restore the purchases. If it exists, you just need to check the expiration date. But the receipt list might be absent. (If user installs a fresh app for instance) Thus you need to get the transactions list from Apple or your server and verify the subscription status – David Sep 23 '15 at 19:38
  • Will i have an updated receipt after the subscription renews? When using sandbox i don't receive a new receipt until i perform restore and the old receipt is expired of course. – Erik Sapir Sep 23 '15 at 20:25