微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ios – SKReceiptRefreshRequest vs restoreCompletedTransactions

我的应用程序使用订阅模式,我收到投诉,其中一些用户无法通过SKPaymentQueue.restoreCompletedTransactions恢复订阅.他们必须删除应用程序并从AppStore重新下载.

我不确定为什么它只发生在一些用户身上,其中一个告诉我他通过itunes取消并重新启动,另一个关于付款问题.

那么为什么他们需要重新下载应用程序呢?我猜测一些信息在收据上没有正确刷新,所以我考虑使用SKReceiptRefreshRequest而不是restoreCompletedTransactions,或者可能同时使用两者.

有人可以解释这两个过程之间的差异吗?

解决方法

SKReceiptRefreshRequest与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.

我们可以同时使用SKReceiptRefreshRequest&恢复已完成的事务以验证用户订阅,但在下面的情况下,我们必须使用恢复已完成的事务而不是刷新收据:

>如果您使用Apple托管的内容,则还原已完成的事务会为您的应用程序提供用于下载内容的事务对象.
>如果您需要支持早于iOS 7的iOS版本(应用程序收据不可用),请恢复已完成的事务.
>如果您的应用使用非续订订阅,则您的应用负责恢复过程.

参考:https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html#//apple_ref/doc/uid/TP40008267-CH8-SW9

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐