如何在SkpaymentTransActionObserver中退还了如何检测到不清楚的应用内项目?

发布于 2025-01-23 20:29:46 字数 1168 浏览 0 评论 0原文

我正在使用本地Storekit进行测试,用于不可消耗的应用内物品。

如果我购买了不可消耗的应用程序内商品,则可以在skpaymentTransactionObserver 中收到回调,

extension IAPHelper: SKPaymentTransactionObserver {
    public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
        for transaction in transactions {
            switch transaction.transactionState {
            case .purchased:
                complete(transaction)
            ...
        }
    }

    private func complete(_ transaction: SKPaymentTransaction) {
        print("complete...")

        // Save purchase record to disk to indicate user owns this non-consumable item.
        persistPurchase(identifier: transaction.payment.productIdentifier)
        
        SKPaymentQueue.default().finishTransaction(transaction)
    }

如果我去debug/ storekit/ manage transactions ...在skpaymentTransactionObserver中。

即使我关闭了应用程序并再次启动应用程序,也没有任何回调skpaymentTransactionObserver,以指示已退还了不可消耗的应用程序内项目,因此我可以阻止用户访问用户应用内项目。

我可以知道吗,是否可以在skpaymentTransActionObserver中退款,是否可以检测到不需要的应用内项目?如果不是,那么正确的方法是什么?

I am testing using local StoreKit, for non consumable in-app item.

If I purchase the non consumable in-app item, I can receive callback in SKPaymentTransactionObserver without issue

extension IAPHelper: SKPaymentTransactionObserver {
    public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
        for transaction in transactions {
            switch transaction.transactionState {
            case .purchased:
                complete(transaction)
            ...
        }
    }

    private func complete(_ transaction: SKPaymentTransaction) {
        print("complete...")

        // Save purchase record to disk to indicate user owns this non-consumable item.
        persistPurchase(identifier: transaction.payment.productIdentifier)
        
        SKPaymentQueue.default().finishTransaction(transaction)
    }

If I go to Debug/ StoreKit/ Manage Transactions... , to perform refund, I do not receive any callback in SKPaymentTransactionObserver.

Even if I close the app and start the app again, there isn't any callback to SKPaymentTransactionObserver, to indicate the non consumable in-app item has been refunded, so that I can block user from accessing the in-app item.

May I know, is it possible to detect a non-consumable in-app item has been refunded, in SKPaymentTransactionObserver? If not, what is the right way to do so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文