Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在SwiftyStorekit中恢复旧用户的订阅?_Ios_Swift_In App Purchase_Swiftystorekit - Fatal编程技术网

Ios 如何在SwiftyStorekit中恢复旧用户的订阅?

Ios 如何在SwiftyStorekit中恢复旧用户的订阅?,ios,swift,in-app-purchase,swiftystorekit,Ios,Swift,In App Purchase,Swiftystorekit,在第一个版本中,我使用了3个产品id 月刊 三个月 及每年订阅 在我新版本的应用程序中,有两个全新的产品id 月 年 所以我的问题是,对于已经购买了旧产品id订阅的老用户,他将如何使用新版本进行恢复 目前,我正在使用下面的代码来恢复购买,但它不会恢复旧的产品id SwiftyStoreKit.restorePurchases(atomically: true) { results in APP_UTILS.hideHUD() for purcha

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

  • 月刊
  • 三个月
  • 及每年订阅
  • 在我新版本的应用程序中,有两个全新的产品id

  • 所以我的问题是,对于已经购买了旧产品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))
            }
    

    使用此代码根据产品ID使用
    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")
            }
        }
    }
    

    如果restoredPurchase中的产品过期了怎么办?我们怎么检查呢?