问题
In the first version, I was using 3 product id's
- Monthly
- Three Months
- And yearly Subscription
And in my new version of app there are 2 product id's, which are totally new
- Month
- Year
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.
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))
}
回答1:
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")
}
}
}
来源:https://stackoverflow.com/questions/52628123/how-to-restore-subscription-for-old-users-in-swiftystorekit