问题
My app uses a subscription model and I´m getting complaints where some users can´t restore their subscription through SKPaymentQueue.restoreCompletedTransactions
. They have to delete the app and re download it from the AppStore.
I'm not really sure why it is happening only to some of the users, one of them told me he cancel and reactivated through itunes, another about a payment issue.
So why do they need to re-download the app? I'm guessing some information is not refreshing properly on the receipt, so I was thinking of using SKReceiptRefreshRequest
instead of restoreCompletedTransactions
, or maybe use both.
Can someone explain the differences between the 2 processes?
回答1:
It is very simple difference between SKReceiptRefreshRequest
vs RestoreCompletedTransactions
:
SKReceiptRefreshRequest
Refreshing the receipt asks the App Store for the latest copy of the receipt. Refreshing a receipt does not create any new transactions. Although you should avoid refreshing multiple times in a row, this action would have same result as refreshing it just once.
RestoreCompletedTransactions
Restoring completed transactions creates a new transaction for every completed transaction the user made, essentially replaying history for your transaction queue observer. While transactions are being restored, your app maintains its own state to keep track of why it’s restoring completed transactions and how it needs to handle them. Restoring multiple times creates multiple restored transactions for each completed transaction.
We can use both SKReceiptRefreshRequest
& Restore completed transactions for validating user subscription, But here in below cases we must used to Restore completed transaction instead refreshing receipt:
If you use Apple-hosted content, restoring completed transactions gives your app the transaction objects it uses to download the content.
If you need to support versions of iOS earlier than iOS 7, where the app receipt isn’t available, restore completed transactions instead.
If your app uses non-renewing subscriptions, your app is responsible for the restoration process.
Reference: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html#//apple_ref/doc/uid/TP40008267-CH8-SW9
来源:https://stackoverflow.com/questions/40897238/skreceiptrefreshrequest-vs-restorecompletedtransactions