【问题标题】:how to restore subscription for old users in SwiftyStorekit?如何在 SwiftyStorekit 中恢复老用户的订阅?
【发布时间】:2018-10-03 13:27:01
【问题描述】:

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

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

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

  1. 年份

所以我的问题是,对于已经使用旧产品 ID 购买订阅的老用户,他将如何使用新版本进行恢复。

目前,我正在使用下面的代码来恢复购买,但它不会恢复旧的产品 ID。

 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))
        }

【问题讨论】:

    标签: ios swift in-app-purchase swiftystorekit


    【解决方案1】:

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

    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")
            }
        }
    }
    

    【讨论】:

    • restoredPurchase中的商品过期了怎么办?我们如何检查?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多