How to update a subscription with StoreKit? - ios

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.

Related

iOS Auto Renewable Subscriptions and Receipt Validation Clarifications

I was wondering if my approach regarding auto-renewable subscriptions is correct.
I have implemented an auto-renewable subscription in my app, it is the only IAP.
When the user launches the app, it performs receipt validation through Apple's servers. When I receive the response I check the expires_date_ms in latest_receipt_info to see if the user is subscribed or not. When I perform receipt validation I also add the exclude-old-transactions tag. I have also added a "Restore previous purchases" function to restore older receipts on the first app launch.
Is my approach correct or I am missing something? Also, do auto-renewable subscriptions auto-renew automatically or do I have to implement the feature by myself?
Thanks in advance for any help.
Regards.
Auto-renewable in-app subscriptions do renew automatically, you don't need to do anything for that. You just need to check if a subscriber has an active subscription when using your app. You can also activate the grace period in App Store Connect for your subscription, so your users will have access for additional 16 days if Apple could not renew the subscription. You can read more here https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/reducing_involuntary_subscriber_churn

Non-renewing sbuscription in iOS

I want to implement InApp purchase in my iOS video streaming app to do that I need to implement Non-renewing subscription e.g 1 month,3 months, 6 months and 1 year.
I am using Objetive-C in my application.
Can you please tell me how to implement it because as per Apple, developer need to manage subscription expiration date and time.
How to validate receipt ??
How to manage user's subscription on multiple device or restore user's subscription if user login on other device ??
Please help me and let me know if anything is required in Non-renewing subscription.
Thanks,
You should go through the in-app purchase programming guide before starting the implementation.
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Introduction.html
Store-kit won't send you any notification in case of subscription end for a non-renewable subscription. You need to calculate the duration on your own and revoke the user's access to your server after that duration.
To verify the receipt you can do the validation on user's device or on your server, but your server is preferably better and even recommended by apple also.
For restoring the purchase you can go through the following doc
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html#//apple_ref/doc/uid/TP40008267-CH8-SW9
Non Renewing subscription
First of non renewing subscription is the consumable keys that means once it purchased it just purchased. Keep in mind Storekit doesnot restore consumable products so you have to manage yourself because StoreKit does not do it as it do in Auto-renewable subscriptions and Non-consumable .
More details about Non renewing subscription :
Does Non-Renewing subscription requires a restore button?
How to manage?
To manage your in-app purchase you have to use server DB. You have to store your all purchases in server DB by using post API.
Benefits:
You can easily maintain the end date of purchase.
You can get each paid account every time user logged in with any device.
Note: Maintain your DB according to your need.

How do I verify IOS In-App Purchasing Receipts in Bulk?

I'm working on an iOS app that will use Apple's in-app purchasing framework to let the user create auto-renewing subscriptions.
I want my server to check periodically that none of the subscriptions have expired. Apple's Receipt Validation Programming Guide describes a verifyReceipt web service that appears to validate a single receipt.
However, if I want to bulk-verify my entire database every few days, is there a better way to do that than a storm of individual verifyReceipt calls?
You don't need to need to bulk-verify your entire database. A subscription is valid for a fixed duration. If the user cancels their subscription then this takes effect at the next renewal period, not immediately.
Apple customer service can refund a subscription if a user has a case (wrong product purchase is one example they give) but this would be a pretty low figure - and your app should also check for a valid subscription when it starts.
So you should only need to verify subscriptions that are known to be expiring "today".
To my knowledge there's no way to send multiple receipts in one bulk request to validate them in the iTunes servers... You have to send one by one. (Multiple requests)...
I don't know if how you are planing to solve this is the best approach. Apple has extended documentation on how to handle auto renewal subscriptions, most of the times you check the validity of the subscription in the app itself.
Check the in-app purchase documentation. It's a very good read if you plan to depend on in-app subscriptions for your business model:
https://developer.apple.com/library/ios/technotes/tn2259/_index.html

How do auto-renewable in-app-purchase subscriptions work?

My application currently allows the user to subscribe to our service using in-app purchase auto-renewable subscription. The app provides images, 12 images per month, and every month the user needs to renew his/her subscription to see the new content.
I haven't work on the auto-renewable model before, so I have built a model to validate the receipt and it works, but should I check if the user subscription expired or not, and, if so, how?
Also, does the app store only allow magazines and newspaper items to be auto-renewable?
I haven't worked on the auto-renewable model before, so any help on this matter would be highly appreciated.
When a user signs up for an auto-renewable subscription, they continue to be charged until they manually cancel it. This is obviously great from a developer’s point of view, because it takes a lot more effort to cancel something than to just let it continue.
You might already be familiar with a class of apps that use auto-renewable subscriptions already: Newsstand.
Newsstand was first introduced in iOS 5, and allows content providers to easily distribute their newspapers and magazines. With it, Apple introduced the auto-renewable subscription model, which allows you to set a subscription duration and manage renewals automatically through the StoreKit framework.
However, Apple has placed some very strict rules around auto-renewable subscriptions, meaning their usage is (usually) exclusive to Newsstand apps.
So sadly, if you want to provide content or features for a limited duration, outside of Newsstand, then your only option is to use non-renewing subscriptions.
found that here: http://www.raywenderlich.com/36270/in-app-purchases-non-renewing-subscription-tutorial
An auto-renewable subscription is an iOS In-App Purchase category that allows an app to provide and charge for content or features over a set amount of time.
Hear is a very useful link!. It provides almost every details about auto renewable subscription
Auto-Renewable In-App purchases continues charging the user (weekly/monthly/yearly etc.) until they cancel it.
You can check if the subscription has expired using the a validated receipt. It contains subscription expiration date and time.
If you want to lock content if subscription has not renewed, you may want to check receipt info against current date/time, on applicationDidBecomeActive delegate. There are open source libraries that lets you verify receipts locally as well.
And any kind of app can have Auto-Renewable In-App purchases, not just newsstand apps.

Check if a non-renewable subscription was refunded by Apple?

I'm getting ready to include in-app purchasing for subscription features in my iOS app. Per what I've read, I need to use a non-renewable subscription type (not auto-renewable). Some customers trick the system and get a refund from Apple but they can still use their app. As a non-renewable subscription has to be handled by an external server (us) we will obviously log the subscription purchase, receipt, etc.
Is there a way in the receipt verification to determine if the subscription is still valid? I'm not sure if the non-renewable subscription type validation is simply testing whether a receipt is valid or if the subscription remains valid.
For example, you make a purchase, the receipt validates. If you cancel your purchase with Apple via an iTunes complaint and Apple grants you a refund, if I were to later verify that receipt again would it come back invalid? I'm wondering if we should build in a frequent validation routine that would catch any subscriptions that have been refunded. We have some terms that will go two years so it's important we verify these on a set schedule. We originally planned to use auto-renewable subscriptions where this scenario does exist as it's the way to determine if the subscription renewed, but now learning a subscription for synchronization will require a non-renewable subscription type.
See this question on refunds.
Apple doesn't provide you a way to determine if a transaction was refunded. Since refunds are officially not supported, they expect you to continue to deliver the goods to a refunded user.

Resources