ios - SKReceiptRefreshRequest 与 restoreCompletedTransactions

标签 ios macos storekit

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

我不太确定为什么它只发生在某些用户身上,其中一个用户告诉我他通过 iTunes 取消并重新激活,另一个是关于付款问题。

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

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

最佳答案

SKReceiptRefreshRequestRestoreCompletedTransactions 之间的区别非常简单:

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 & Restore completed transactions来验证用户订阅,但是在下面的情况下我们必须使用Restore completed transaction而不是刷新收据:

  • 如果您使用 Apple 托管的内容,恢复已完成的交易会为您的应用提供用于下载内容的交易对象。

  • 如果您需要支持 iOS 7 之前的 iOS 版本,应用收据不可用,请恢复已完成的交易。

  • 如果您的应用使用非续订订阅,您的应用将负责恢复过程。

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

关于ios - SKReceiptRefreshRequest 与 restoreCompletedTransactions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40897238/

相关文章:

iOS收据不包含 repo 交易

ios6 - SK产品本地化不同语言的描述

ios - 我可以将 TDAudioStreamer 与 GCDAsyncSocket 或 NetService 一起使用吗?

ios - TwitterKit 3.3.0 的 TWTRSession 问题

macos - 编译用于链接 OSX 的二进制文件

macos - 当我没有 Mac 时,在 Mac/Safari 上测试 Web 应用程序

ios - 如何在单击按钮时关闭选项卡栏 Controller 并返回到上一个 View Controller

ios - 使用 PlistBuddy 获取应用程序版本返回 "CFBundleShortVersionString does not exist"

mysql - MAMP(PRO) mysql 是否会与 brew install mysql 在 macos 上冲突

ios - SKPaymentQueue.canMakePayments() 总是返回 true