Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

swift

storekit

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!

like image 442
SwiftyLifestyle Avatar asked Sep 15 '18 13:09

SwiftyLifestyle


1 Answers

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.

like image 61
Giordano Scalzo Avatar answered Oct 16 '22 14:10

Giordano Scalzo