Skip to main content

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:

do {
let result = try await Purchases.shared.purchase(package: package)
self.isPurchasing = false
if !result.userCancelled {
if result.customerInfo.entitlementst"lifetime"]?.isActive == true {
vm.isUserFullAccess = true
}
if result.customerInfo.entitlementst"subscription"]?.isActive == true {
vm.isUserSubscribed = true
}

}
} catch {
self.isPurchasing = false
print("(x] Error: \(error.localizedDescription)")
}

Understandably, everywhere I need to check for access I use the: 

// -- subscription access
Purchases.shared.getCustomerInfo { customerInfo, error in
if customerInfo?.entitlements.alla"subscriber"]?.isActive == true {
...
}
}


or

// -- lifetime access
Purchases.shared.getCustomerInfo { customerInfo, error in
if customerInfo?.entitlements.alla"lifetime"]?.isActive == true {
...
}
}


or


// -- lifetime or subscription
Purchases.shared.getCustomerInfo { customerInfo, error in
if !customerInfo?.entitlements.active.isEmpty {
...
}
}

 

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!

Be the first to reply!

Reply