如何在SwiftyStorekit中恢复旧用户的订阅? [英] how to restore subscription for old users in SwiftyStorekit?

查看:312
本文介绍了如何在SwiftyStorekit中恢复旧用户的订阅?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在第一个版本中,我使用了3个产品ID.

In the first version, I was using 3 product id's

  1. 每月
  2. 三个月
  3. 年度订阅

在我的新版本应用中,有2个产品ID,它们是全新的

And in my new version of app there are 2 product id's, which are totally new

  1. 年份

所以我的问题是,对于已经购买了带有旧产品ID的订阅的旧用户,他将如何使用新版本进行还原.

So my question is, for old users who have already purchased a subscription with old product id's, how he will be able to restore with the new version.

目前,我正在使用下面的代码来还原购买的商品,但它不会还原旧产品的ID.

Currently, I m using below code to restore the purchase, but it doesn't restore old product id's.

 SwiftyStoreKit.restorePurchases(atomically: true) { results in
            APP_UTILS.hideHUD()
            for purchase in results.restoredPurchases {
                if purchase.needsFinishTransaction {
                    // Deliver content from server, then:
                    SwiftyStoreKit.finishTransaction(purchase.transaction)
                }
            }
            //self.showAlert(self.alertForRestorePurchases(results))
        }

推荐答案

使用此代码根据带有 SwiftyStoreKit 的产品ID恢复应用内购买:

Use this code to restore In App Purchases based on the product ID with SwiftyStoreKit:

SwiftyStoreKit.restorePurchases(atomically: true) { results in
    for product in results.restoredPurchases {

        if product.needsFinishTransaction {
            SwiftyStoreKit.finishTransaction(product.transaction)
        }

        if product.productId == "PASTEPRODUCTID1HERE" {
            print("PRODUCT 1 is restored")
        } else if product.productId == "PASTEPRODUCTID2HERE" {
            print("PRODUCT 2 is restored")
        }
    }
}

这篇关于如何在SwiftyStorekit中恢复旧用户的订阅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆