How to restore your single In-App Purchase in iOS

This is an addition to my previous article. To allow uses to restore their In-App Purchases you can expand on the previous article and include the following method in your Shop class. This needs to be public so it can be called from your main class:

Much like submitting a payment, this now submits a “restore request” to the app store, which in turn will get back to us via the observer delegate. Here’s the implementation from before (still in AppDelegate.m), with the addition of a fleshed out reaction to the restore:

We let the user know about a successful restore (or failure) via an alert view. Since I’m calling this multiple times it was easier to create a method for this:

Note that you should validate the purchase before restoring it. The Apple documentation goes on a bit about receipt validation without describing a way to actually do it.

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

Add your voice!