gpt4 book ai didi

ios - 何时刷新收据与恢复 iOS 中的购买?

转载 作者:可可西里 更新时间:2023-11-01 03:50:38 25 4
gpt4 key购买 nike

我们的 iOS 应用使用应用内购买,包括一次性订阅和自动续订订阅。这两者都是非消耗品。

iOS 提供了两个 API:refresh receipt , 和 restore completed transactions .

似乎后者适用于所有情况,而前者仅适用于某些情况。具体来说,当我们将自动续订购买恢复到新设备时,恢复购买的交易将导致 future 的续订生成交易,该交易将在后台发送到新设备,而刷新收据不会导致交易下次续订时发送到此设备。

鉴于此,是否有任何理由使用刷新收据?

Apple 似乎说我们可以使用其中之一:

Retrieve information about past purchases by either refreshing the app receipt using the SKReceiptRefreshRequest class or restoring completed transactions using the restoreCompletedTransactions method of the SKPaymentQueue class.

最佳答案

您需要阅读此 Restoring Purchased Products了解两者之间的目的。

从 iOS 7 开始,从商店下载的每个应用程序在 appStoreReceiptURL 都有一个收据(用于下载/购买应用程序)。当用户通过 In App Purchase 购买东西时,appStoreReceiptURL 中的内容会更新购买信息。大多数情况下,您只需刷新收据(位于 appStoreReceiptURL),以便了解用户进行了哪些交易。

Users restore transactions to maintain access to content they’ve already purchased. For example, when they upgrade to a new phone, they don’t lose all of the items they purchased on the old phone. Include some mechanism in your app to let the user restore their purchases, such as a Restore Purchases button. Restoring purchases prompts for the user’s App Store credentials, which interrupts the flow of your app: because of this, don’t automatically restore purchases, especially not every time your app is launched.

In most cases, all your app needs to do is refresh its receipt and deliver the products in its receipt. The refreshed receipt contains a record of the user’s purchases in this app, on this device or any other device. However, some apps need to take an alternate approach for one of the following reasons:

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.

Refreshing the receipt asks the App Store for the latest copy of the receipt. Refreshing a receipt does not create any new transactions.

Restoring completed transactions creates a new transaction for every completed transaction the user made, essentially replaying history for your transaction queue observer.

有关收据的更多信息,来自 WWDC 2017,StoreKit session 中的新功能 https://developer.apple.com/videos/play/wwdc2017/303/

enter image description here

您还可以观看 WWDC 2017 session Advanced StoreKit 了解更多详情 https://developer.apple.com/videos/play/wwdc2017/305/

enter image description here

关于ios - 何时刷新收据与恢复 iOS 中的购买?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45615106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com