restoreCompletedTransactions进行应用

restoreCompletedTransactions进行应用

本文介绍了何时使用restoreCompletedTransactions进行应用内购买?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

对于使用非消费类应用内购买的基本应用,有没有人想出使用SKPaymentQueue的 restoreCompletedTransactions 的最佳做法?

For a basic app with nonconsumable in-app purchases, has anyone figured out best practices for using SKPaymentQueue's restoreCompletedTransactions?

我知道建议始终注册一个事务观察者来接收返回到应用程序的待处理事务,但这是一个不同的问题。看起来 restoreCompletedTransactions 是应用程序必须主动决定何时调用以进行客户已经进行的所有购买的轮询。

I know it's recommended to always register a transaction observer to receive pending transactions that make their way back to the app, but this is a different question. It looks like restoreCompletedTransactions is something the app has to actively decide when to call to poll for all the purchases the customer has already made.

据我所知,该方法旨在检索可能已丢失的购买。例如,客户可能会以这样的方式安装或移动应用程序到新设备,其中应用程序的先前付款的本地记录丢失或重置。

From what I can tell, the method is designed to retrieve purchases that may have been lost. For example a customer might install or move an app to a new device in such a way where the app's local records of previous payments are lost or reset.

我不清楚如何以可靠的方式自动检测这种情况(即如何决定何时轮询丢失的购买)。我不想搞砸了,并且有可能拒绝客户访问他们已经支付的功能。

What's not clear to me is how to automatically detect this condition (i.e. how to decide when to poll for missing purchases) in a reliable way. I don't want to screw this up and risk denying a customer access to functionality they've already paid for.

同时,我不想调用 restoreCompletedTransactions 每次启动应用程序只是为了安全,并基本上回复我已经知道的99.9%的交易。 (除了应用内购买,我的应用并不需要任何网络连接。)

At the same time, I don't want to call restoreCompletedTransactions every single time the app launches just to be safe and basically get back transactions I already know about 99.9% of the time. (Except for in-app purchasing, my app doesn't really require any network connectivity.)

Apple文档澄清了客户不会再次因他们已经进行的任何非消费性购买而被收费。如果他们试图重新购买,付款交易仍然会被发送到应用程序。

Apple documentation clarifies that customers are not charged again for any nonconsumable purchases they have already made. If they try to re-purchase, a payment transaction is still supposedly sent to the app.

最糟糕的情况是,客户可以通过这种方式恢复购买,但我仍然我希望避免让他们走上类似于重新购买他们已经支付过的东西的路径。

Worst-case, a customer could recover purchases this way but I'd still like to avoid walking them down a path that resembles re-purchasing something they've already paid for.

推荐答案

写完之后问题和想法,我提出了几个解决方案。

After writing out the question and thinking about it, I came up with a couple solutions.

一个选项是在用户默认值中记录是否已在应用程序中调用(并成功完成) restoreCompletedTransactions 。如果没有,应用程序会在启动时调用它一次。由于此标记可以存储在与非消费支付相同​​的位置,如果稍后用户默认值被删除,则应用程序启动时将再次调用恢复方法。

One option is to record in user defaults whether restoreCompletedTransactions has been called (and successfully completed) yet in the app. If not, the app calls it once on start-up. Since this flag could be stored in the same place as the nonconsumable payments, if user defaults get wiped later on then the restore method would get called again when the app starts.

这样,如果现有客户以某种方式重新安装应用程序,他们仍然可以自动恢复购买。如果他们是以前从未启动过应用程序的新客户,则还原操作不会返回任何内容。

This way, if an existing costumer is somehow doing a fresh install of the app they still get their purchases restored automatically. If they are a new customer that has never launched the app before, then the restore operation returns nothing.

在任何一种情况下, restoreCompletedTransactions 只调用一次而不是每次启动。

In either case, restoreCompletedTransactions is only called once instead of at every launch.

另一个选项是在某处向客户提供恢复购买按钮,将其连接到 restoreCompletedTransactions ,让他们决定是否以及何时需要它。

Another option is to offer the customer a "Restore Purchases" button somewhere, hook it up to restoreCompletedTransactions and let them decide if and when it might be needed.

(以下评论说明为什么手动恢复可能比尝试自动执行更好。)

(The comments below go into why a manual restore is probably better than attempting to do it automatically.)

这篇关于何时使用restoreCompletedTransactions进行应用内购买?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 16:29