PeterStaev / nativescript-purchase

:moneybag: A NativeScript plugin for making in-app purchases!
Apache License 2.0
83 stars 28 forks source link

Leaving already purchased goods outside the listView #77

Closed MariSpr closed 5 years ago

MariSpr commented 5 years ago

Hey Peter, first of all, thanks for this great plugin! It helps a lot ppl like me who arent so experienced with programming hardcore stuff :-)

I have searched thru the old issues/postings but couldnt really find code for doing such but anyway, I would like to ask if its possible to get only "purchasable" products to be displayed on the listview?

And if I have a consumable item which can be bought multiple times, how to handle it as the app will return the error it was already bought...

Thanks in advance! :-)

Mariana

PeterStaev commented 5 years ago

Hey @MariSpr ,

Not sure what do you mean under "purchasable" products. Basically all products are purchasable 😉

For consuming there is already a sample code in the Usage section in the readme. Also there are examples in the detailed tutorial, for which you can find links at the end of the readme.

UPDATE: Reading the title of the issue I think I understand what do you mean to show only "purchaseable" items. One way to do it is call resotrePurchases. This will return restore transactions for all purchased goods. so you can get the product IDs and then exclude those from the list. A better option would be to have what is purchased stored on the device local storage. I have this demonstrated on the step by step guides as well. Then you can simply check if the given product ID is present in the local storage, and if it is present then to remove it from the source of your ListView.

MariSpr commented 5 years ago

Hey Peter, thanks a lot for your answer!

Yeah, this is exactly what I meant :-) I saw the part of the tutorial where you save the ID into the application-settings, but I wonder how to erase it?! Sth. like applicationSettings.setBoolean(transaction.productIdentifier, false); ??

I would be very happy to see a bit of a code sample! 👍

Thanks in advance, Mariana

PeterStaev commented 5 years ago

Correct. Setting it to false is how you mark the product id as not purchased.

PeterStaev commented 5 years ago

No further response so closing this one for now.