Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 747
cannyboy Avatar asked Feb 24 '13 18:02

cannyboy


1 Answers

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.

like image 107
LuisEspinoza Avatar answered Oct 22 '22 10:10

LuisEspinoza