我希望能够确定用户是否曾经订阅过能够更改购买按钮的名称。换句话说,在开始按钮会说,Try It Now
如果用户当前订阅按钮会说Subscribed
但是如果用户曾经被订阅但订阅已过期我想显示Renew
在购买按钮上。
目前一切正常,除了Renew
选项。
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Purchases.shared.purchaserInfo { (purchaserInfo, error) in
self.configurePurchases(purchaserInfo: purchaserInfo)
}
}
func configurePurchases(purchaserInfo: PurchaserInfo?) {
if let purchaserInfo = purchaserInfo {
if purchaserInfo.activeEntitlements.contains("myKillerFeatureEntitlement") {
myButton.setTitle("Subscribed",for: .normal)
labelAutoTaxDescription.text = "You are currently subscribed. Thank you for your support."
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .medium
if let expirationDate = purchaserInfo.expirationDate(forEntitlement: "myKillerFeatureEntitlement") {
self.labelAutoTaxDetectionPrice.text = "Expiration Date: \(dateFormatter.string(from: expirationDate))"
}
}
}
// Here is where I need check if it's a returning user so I can change the name of the button
if isReturningUser{
myButton.setTitle("Renew",for: .normal)
// other code
}
}
检查用户之前是否订阅过的最佳方法是什么?