iOS - retrieving latest receipt after subscription auto renewd - ios

I would like to offer a monthly subscription (as In App Purchase) to my users. When the user buys a subscription a receipt is stored on the device with an expiration date one month after purchase date. My question is how i should retrieve a new receipt after this month is passed and the subscription auto renewed?
What i am doing now is to perform refresh receipt using SKReceiptRefreshRequest when i recognize that there is an expired receipt on the device. The problem with this method is that it triggers the "Sign in to iTunes Store" popup. I am testing the app using sandbox users.

Managing subscriptions with In-App Purchase minute 21:00 exactly.
This happens automatically when user opens your app. The implemented delegate will receive any waiting new receipts.

Related

How Do I know that auto Renewalbe subscription is cancelled or not?

I am implementing In App purchases in my app ,with auto renewable subscription , Now i am confusing that how i know that when the user is cancelled auto-renewable subscription or not
When user purchase any subscription using in app purchase, apple provide a Receipt for each purchase or transaction. Now you can anytime verify the subscription of user using this receipt. When you will pass this receipt to apple server it will provide you with the user current subscription (if available) along with the current receipt also.
For learning more about receipt validation go through this apple link. May be it will solve your issue.
You need to track the expiration date of the current subscription. If you don't get a new subscription transaction at the start of the next period you can assume that the renewal has been cancelled.
From the In-App Purchase Programming Guide -
After a subscription is successfully renewed, Store Kit adds a
transaction for the renewal to the transaction queue. Your app checks
the transaction queue on launch and handles the renewal the same way
as any other transaction. Note that if your app is already running
when the subscription renews, the transaction observer is not called;
your app finds out about the renewal the next time it’s launched.

How to manage the InAppPurchase subscriptions

I am doing one application.In that i implemented In App Purchase with Auto renewal subscription.First i subscribed for one month and got the receipt from apple.And when i try to send the receipt to server,due to some problem i am unable to send a receipt to my server.And i didn't store the receipt in my local DB also.Whenever next time i will try to open my application,my server giving the alert like "Please subscribe".So if i try to subscribe once again,apple will again deduct the money or not.Can i get the receipt from the apple.
Every user can only have one subscription at one time. Apple give him an alert that he already has this subscription.
You have to implement subscription restoring option for users. Here is a nice guide in the Apple Docs

How to update a subscription with StoreKit?

I'm trying to work out the best mechanism to handle the auto renewing part so that it handles the continuation of the subscription into the next period.
What the best way of handling this?
Should I have an NSTimer set to check if the current expires_date has been reached .. and then try send a purchase request?
Apple iOS in-app purchases provides the product "Auto-renewable subscription". This product will be renewed automatically by Apple.
When you use this type of product, your app has to verify if the auto-renewable subscription is still valid, since the user might have cancelled the subscription. When an user cancel a subscription, the subscription remains valid until the end of the subscription period.
To validate an auto-renewable subscription, you have to use the purchase receipt and the shared secret generated for your app in-app purchases in iTunes Connect. You have to post this two things to the App Store. This will return a JSON and you have to get from this data the "
subscription's latest purchase date". From that date you have to calculate the expiration date and validate or invalidate the subscription.
You can do all this validation after application launch and/or when the model is updated.
Additional information
You can find information about auto-renewable subscription in Apple documentation. Also, you can check about MKStoreKit, which is a framework that reduces the amount of code that you have to write for the use of StoreKit, and supports Auto-renewable subscriptions.

IOS subscription end notification

I am looking to build a ios application that will use an auto-renewable subscription on a monthly biases. We will be using some VOIP features that we will be charged monthly for. My question is, how can we be notified when a user cancels a subscription in IOS, so that we can cancel the users VOIP telephone number with our provider.
You will need to verify the receipt the same way you do for regular In App Purchases, but obviously you will do this every time the subscription period expires. Check out the documentation on this, Verifying an Auto-renewable Subscription Receipt
So based on this, it appears you will need to setup your server to check for a valid subscription every month (cron job?). This will allow you to cancel the VOIP number in your system if the subscription is no longer valid. Your app would be responsible for verifying a subscription is still valid when it is opened or the user attempts to access features that require a subscription.
Updated For Comment
The sandbox is supposed to return expiration dates in the following scheme.
This is from page 164 of the iTunes Connect Developer Guide
If it is not working this way you may want to file a bug report.
Also, please not the following from Apples IAP doc:
Additionally, a sandbox subscription will only autorenew a maximum of 6 times. After the subscription has auto-renewed 6 times, it will no longer renew in the sandbox.

iOS - Inapp purchase - subscriptions

I'm having in-app purchase subscriptions in my app. I'm able to integrate and make subscriptions successfully. There are 3 different subscriptions, monthly, quarter and yearly.
So if user subscribes to monthly user can use that feature for 30 days. There's no server in my case. Only availability of some features will be activated/deactivated according to subscription.
When ever the app starts, i want to check whether user paid for subscription or not. If I'm maintaining some bool value in subscriptions, what if the user has deactivated the subscriptions from settings? How can I detect whether the subscriptions are valid or not?
You can add counter and add that counter value in a database that must be inside your app. Whenever user tries to access subscriptions you can verify from the database.
You have to post the receipt back to apple server and from the response we receive, we can identify the expiry date. Then I'll know whether the subscription is expired or renewed etc.
Visit Apple documentation

Resources