3

I'm trying to add purchases to my application. But I don't know how to check if purchase is already bought. As far as I understand when somebody bought purchase I need to store this into UserDefaults or KeyChain and then check if it is already there (it mean that this purchase is already bought). But what about when user bought this purchase prom another device?

I have code that give me information about all purchases in iTunes.

func productsRequest(request: SKProductsRequest!, didReceiveResponse response: SKProductsResponse!) {

    }

Response object have two variables: "products" and "invalidProductIdentifiers". But as I understand products contain all products from iTunes and invalidProductIdentifiers contain all identifiers that I was asking to check for but Apple can't recognise them. So where I can check if purchase was already bought or not.

jscs
  • 63,694
  • 13
  • 151
  • 195
Vasyl Khmil
  • 2,548
  • 1
  • 20
  • 36
  • 3
    What you need is to offer a restore button. And do the IAP Restoring Purchased Products as in this: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html – user523234 Feb 08 '15 at 14:48
  • Possible duplicate of [A complete solution to LOCALLY validate an in-app receipts and bundle receipts on iOS 7](http://stackoverflow.com/questions/19943183/a-complete-solution-to-locally-validate-an-in-app-receipts-and-bundle-receipts-o) – CAMOBAP Aug 15 '16 at 13:59

1 Answers1

1

Assuming iOS 7+, you should be validating the receipt, ala A complete solution to LOCALLY validate an in-app receipts and bundle receipts on iOS 7 to determine what's purchased, what's valid (in the case of subscriptions or consumables), and as noted in the other comment, offer a "Restore Purchases" UI element which allows users to cleanly propagate sharable purchases to a newly restored/acquired device.

AFA the response object, that is catalog (purchasable items) information, not info on what has been purchased. In order to have IAP work correctly, assets are to be approved by Apple similarly to the app itself as well as being under "ready for sale" control of your own in iTunes Connect. For that pass, you send Apple a complete list of the times you want to offer and Apple returns to you the list split into the "if your user tries to buy this, they will succeed" (the products) and "if your user tries to buy this, they will fail" (the invalidProductIdentifiers).

When you're testing with sandbox/iTunes Connect Test users, your products do not need to be approved by Apple, but for production code they do.

Community
  • 1
  • 1
Brad Brighton
  • 2,179
  • 1
  • 13
  • 15