how to detect the renewal status in apple auto subscription development? - ios

there is a way if the server verify the receipt the apple will return the latest_receipt_info which contains the expires_date of auto subscription.But what time and what way to do this check? everyday the server to do this check or the app to do this when it's opened,should I always take the first buy receipt to post http://buy.itunes.apple.com/veriryreceipt for get the latest_receipt_info?
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html
is there a good way to check the renewal status?

Related

How to handle renewal of the auto-renewable subscriptions locally?

I try to add auto-renewable subscriptions in my app, but not sure about the proper way to handle this.
What I'm having right now is
Add SKPaymentQueue.default().add(self) in app delegate.
Once user purchase I save expiration date and set timer to fire on that date.
If I get renew transaction, update expiration date and extended timer.
If user not renew timer will fired and update ui to reflect that change.
My question is if this a right approach? This approach seem to have a gap where a brief moment (when date expired and renew transaction not yet arrived), users are treat as free tier.
What is a better way to do this?
The app receipt contains a record of the user’s purchases, cryptographically signed by Apple. You can validate subscription receipt in two ways:
Locally/Unsafe: Perform receipt validation immediately after your application launched.
Remotely/Safe: Perform receipt validation at server end. Use trusted
server to connect with App Store.
For more information, see Receipt Validation Programming Guide.

Issue with auto renewable subscription and status update notifications ios (swift)

We have got a problem with auto renewable subscription.
First, I would like to tell you my case from the beginning to understand my problem totally.
So, I have an app that contains auto renewable subscription. I managed to buy a product from my app, but I would like to validate the receipt from my server. If I understand it well, then I should send the receipt data to my server that will send the receipt data to Apple and verify that receipt.
First question is that, do I know it right that verification means that we send a request to https://sandbox.itunes.apple.com/verifyReceipt ?
Secondly, what happens if I cannot send the receipt data for the server? I mean, in this case should I save the receipt data locally and try to send it again in a different time (my app can be used after registration so I have to send the user id with receipt data to my server)?
Furthermore, there is a subscription status URL for auto renewable subscription in iTunes connect. We set up an URL for this but we do not get any notification from Apple's server. We configured the server as explained in Apple's documentation (protocols, etc.) but we still don't get any notification. Do you have any suggestion why is it?
Do I know it well, that the notifications should be sent automatically if any status update change happens? If not then what should I do in my app or on my server? (e.g. how to detect if user cancels a subscription?)
Do I have to implement both logic for the best user experience?
To validate the receipt you can send it on apple servers, "can" because you can validate the receipt also in app. In this case is not fully safe, because someone can attack you app and tamper your validation code.
Apple has 2 different kind of servers test and production, when you are debugging you send receipt to the test servers, that also means that auto renewable subscription have shorter time, if I remember well a month in test is 5 minutes.
This is documented very well in apple documentation.
A receipt is always present in your app even if it's free. It's up to you how to manage those kind of situation, in my opinion a receipt should aways be valid from the beginning until the server responds in a different way.
The third question is not clear. There is a system to refresh a subscription but this should be done with user permission as far as I know, the subscription itself seems to be already updated automatically from time to time by the purchase mechanism.
You must implement all the logic to manage a subscription, cancellation, revocation etc.

iOS INApp Purchase Auto renewal subscription?

I have implemented auto renewable subscription (Monthly and Yearly Renewal).I have purchased successfully and verified the receipt. But I don't know how to verify the recipet when subscription auto renewed.(Successfully OR failed). SO please help
There are two approaches. First, your app get notified, when subscription is renewed, actually new purchased transaction received, and you should resend receipt to your server or locally on device set proper configuration. Second, in apple response of receipt validation there is a field "latest_receipt_info", you can retry receipt validation on server in the end of period of subscription and get actual info about your subscription (for instance, if client can't send receipt for some reasons). Combined approach is the best way.

iOS In App Purchase Non Renewing Subscription Receipt Validation

I am trying to understand if it is possible (or not), from within an app targeted at iOS7, to check if a Non Renewing Subscription receipt has been cancelled by Apple?
I thought there was a way to check for a Cancellation Date in the receipt, however, I can't see how you can re-request a Non Renewing Subscription receipt?
Any advice greatly appreciated.
For information, I have found that if a receipt is verified against the AppStore servers there is a field cancellation_date within the formatted data from the receipt that is returned.
So, if you post the receipt from your main bundle up to Apple to verify, the returned data will show any cancellation date. If this date is present Apple state to treat the transaction as never having occurred. See here for more details https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1

How do I know if a user cancels an auto renewing subscription with In-App Purchases on iOS?

I have been testing out Apple's In-App Purchases (sandbox mode) which is great for testing what happens when a user subscribes, but how do I tell if the user is still paying? How do I know if the subscription has been canceled? Apple doesn't appear to let me test that out?
I see that there is something about verifying receipts? How can I do this?
When you subscribe a auto-renewable subscription from app, you will get a receipt. Send that receipt to your server and your sever can use that receipt to verify if your purchase is valid from iTune store (check their doc)
You will get a JSON response and some field inside can show you the expired date.
As to user's cancel, sorry, you cannot know that until current period expire (actually you will know that 24 hours before expiration due to apple store's mechanism)
Hope this helps.
[Updated # 2017/11/5]
Now Auto-renewable subscription is allowed to notify your sever when new period begins. Please check latest document.

Resources