问题
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