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

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...