Hi! I’m fairly new (started today) to using Revenue Cat so I may have missed it in the plethora of documentation. But when a user purchases an item, is there a way to tell what type was purchased?
So, for example, if I wanted to open sections of my app based on whether they subscribed or if they bought a temp access.
Would this be the correct way of implementing it:
1do {2 let result = try await Purchases.shared.purchase(package: package)3 self.isPurchasing = false4 if !result.userCancelled {5 if result.customerInfo.entitlements["lifetime"]?.isActive == true {6 vm.isUserFullAccess = true7 }8 if result.customerInfo.entitlements["subscription"]?.isActive == true {9 vm.isUserSubscribed = true10 }1112 }13} catch {14 self.isPurchasing = false15 print("[x] Error: \(error.localizedDescription)")16}
Understandably, everywhere I need to check for access I use the:
1// -- subscription access2Purchases.shared.getCustomerInfo { customerInfo, error in3 if customerInfo?.entitlements.all["subscriber"]?.isActive == true {4 ...5 }6}789or1011// -- lifetime access12Purchases.shared.getCustomerInfo { customerInfo, error in13 if customerInfo?.entitlements.all["lifetime"]?.isActive == true {14 ...15 }16}171819or 202122// -- lifetime or subscription23Purchases.shared.getCustomerInfo { customerInfo, error in24 if !customerInfo?.entitlements.active.isEmpty {25 ...26 }27}28
I’m trying to wrap my head around it and see if I can differentiate between the user types.
I’ve tagged iOS but I’m working solely on macOS - which is making testing harder than iOS it seems!