我有一个正在运行的 RevenueCat 实施,但我不喜欢这个流程并且正在努力改进它。我知道必须有一种更精致的方法来做到这一点,所以任何帮助将不胜感激:
@IBAction func btnMnthlyPressed(_ sender: Any) {
Purchases.shared.offerings { (offerings, error) in
if let e = error {
print(e.localizedDescription)
}
guard let offering = offerings?.current else {
print("No current offering configured")
return
}
for package in offering.availablePackages {
print(package.identifier)
if package.identifier == "$rc_monthly" {
Purchases.shared.purchasePackage(package) { (transaction, info, error, cancelled) in
if cancelled {
print("User cancelled purchase")
return
}
// Optionally handle specific purchase errors
if info?.entitlements.all["FullAccess"]?.isActive == true {
print("Unlocked Pro Cats ")
}
}
}
print("Product: \(package.product.localizedDescription), price: \(package.localizedPriceString)")
}
}
}
也许我试图在功能上做太多...