OGeek|极客世界-中国程序员成长平台

标题: ios - 使用未完成的事务在 iOS 中跨设备共享消耗品? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 15:11
标题: ios - 使用未完成的事务在 iOS 中跨设备共享消耗品?

TL;DR 你能推迟 iOS 中消耗品的 finishTransaction 调用来模仿机器人的 consumeAsync 吗?

在 Android 中,您可以购买一件商品,该商品最终会出现在由结算 api 管理的列表中。并且可以通过queryPurchaseHistoryAsync访问.

然后可以稍后消费一个项目。购买和消费是两个不同的东西。

帐户在我们的应用程序中是可选的,我们使用 android 中描述的功能来跟踪用户在丢失他/她的设备时已购买/但尚未消费的元素。

SKPaymentQueue 上的文档不清楚关于多设备同步。

The contents of the queue are persistent between launches of your app.

但实际上,它似乎是在设备之间交换的。

虽然不同sources建议您自己管理消耗品的状态。

我想知道是否可以通过保留消耗品 SKPaymentTransaction 来将 SKPaymentQueue 用作单一事实点在 purchased状态。因此,我不会调用 finishTransaction在元素实际消耗之前。

理论上,交易应该保留在 SKPaymentQueue 中,并且应该转移到使用同一个 AppStore 帐户登录的所有设备。

一旦在其中一个设备上完成交易,它就应该从队列中移除,并且信息应该再次传播到所有设备。

我在某处找不到这种方法,我想知道我是否在这里遗漏了一些重要的东西。



Best Answer-推荐答案


您绝对应该在 iOS 上完成交易:

StoreKit will call your observer’s paymentQueue(_:updatedTransactions every time that your app launches or resumes from background until they are removed. To that effect, your customers may be repeatedly asked to authenticate their purchases or be prevented from purchasing your products. https://developer.apple.com/library/archive/technotes/tn2387/_index.html#//apple_ref/doc/uid/DTS40014795-CH1-BEST_PRACTICES-FINISH_THE_TRANSACTION

和安卓:

Consume purchase corresponding to the given purchase token. This will result in this item being removed from all subsequent responses to getPurchases() and allow repurchase of items of the same sku. https://developer.android.com/google/play/billing/billing_reference#consumePurchase

实现多设备支持的正确方法是使用服务器来验证和跟踪用户购买的产品。有了服务器就可以实现,不仅可以实现设备同步,还可以实现多平台支持。

您还可以使用 RevenueCat 之类的服务这一切都为您解决了问题。

关于ios - 使用未完成的事务在 iOS 中跨设备共享消耗品?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55076694/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4