Ios how to get a list of already purchased products?

时光毁灭记忆、已成空白 提交于 2019-12-17 20:28:51

问题


I'm building an app that uses In app purchase. I'm using non-consumable product types.

Everything works ok (setting up products, buying...).

What I would like to do is to verify which products a user had already purchased (when reinstalling app or changing device)?

Is that possible?

Thanks


回答1:


See the Restoring Transactions section of the In-App Purchase guide. Here is what it specifically says:

Store Kit provides built-in functionality to restore transactions for non-consumable products, auto-renewable subscriptions and free subscriptions. To restore transactions, your application calls the payment queue’s restoreCompletedTransactions method. The payment queue sends a request to the App Store to restore the transctions. In return, the App Store generates a new restore transaction for each transaction that was previously completed.




回答2:


you can call

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

it will return to you the already completed transactions.

Then you can verify if your product is in the set.




回答3:


Apple deals with this topic under Restoring Transactions in the In-App Purchase Programming Guide.

Basically, what you have to do is send a restoreCompletedTransactions message to the payment queue.



来源:https://stackoverflow.com/questions/9537663/ios-how-to-get-a-list-of-already-purchased-products

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!