Search code examples
swiftstorekit

Storekit: How to check if the product is purchased or not?


I think everyone knows that Apple In-App Purchases are a little bit difficult thing to implement. (Especially for Swift newbies).

Anyway, I tried to learn working with it. Maybe it's better to say that I followed the tutorial Kilo Loco made on YouTube. Here

I did everything what he did and it's working but it's obvious that I don't understand everything yet.

My question is.. how to check if the customer already purchased it or not?

Maybe there's some kind of status?

Then I would just write something like that:

if(status=="purchased")
{
   // I would do something what premium user can do.
}

I know it's not really clear but I guess who have more experience in it can help me to understand more. (or maybe I should go watch tutorial once again and once again)

THANK YOUU!


Solution

  • You can check this tutorial, the section about Purchased Items. In short, you should save locally if the Item has been already purchased, maybe in UserDefaults A more secure alternative is to validate the receipt of the purchase, as shown in the Apple Documentation.