Question

I need to design an app which use In App Purchase. In this app I have to use StoreKit (obviously!) and also I want to store a list of people who bought app and check them with my own web service. This is because of some jailbreak feature which can delude app store

What I did comes in following:

1. If user wants to use special feature and haven't bought it:

1.1 First I check In User Defaults and Check If User purchased the feature.

1.2 If not I show him/her apple page store and ask him/her to buy.

1.3 After confirmation I send data to my web service and also save it in User Defaults.

2. If user wants to use special feature and have bought it:

2.1 First Check if anything has stored in User Defaults

2.2 If nothing has bought show him/her page store

2.3 After getting has already purchased message from store I check it with my web service

2.4 If web service confirmed already purchased message then I let user use feature and save it in User Defaults.

I have problem with choosing a unique identifier which works among all apple devices.

Was it helpful?

Solution

You don't need to identify the device, you need to validate the transaction. The user should be able to restore purchases across re-installations and across devices.

The In-App Purchase programming guide states -

Persisting Using Your Own Server Send a copy of the receipt to your server along with some kind of credentials or identifier so you can keep track of which receipts belong to a particular user. For example, let users identify themselves to your server with an email or user name, plus a password. Don’t use the identifierForVendor property of UIDevice—you can’t use it to identify and restore purchases made by the same user on a different device, because different devices have different values for this property.

So, once you have the receipt you can send it to a web service. You can use a shared secret or a public/private key pair to sign the receipt so that your server can validate it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top