Hey @Tim Mitra !
You can listen to the customerInfo during the purchase of the paywall by calling the following:
purchaseCompleted: { customerInfo in
print("Purchase completed: \(customerInfo.entitlements)")
}
More information on this can be found in the code block here: https://www.revenuecat.com/docs/displaying-paywalls#ios
Hope that helps!
I’m doing that but not at the app level. I want my users to be able to perform some actions deeper in the app. When they reach a number of activities, I’m using PaywallView(), but there doesn’t seem to be a reliable way to get notice that the purchase was successful.
.task {
do {
let customerInfo = try await Purchases.shared.customerInfo()
isProUser = customerInfo.entitlementsl"Pro"]?.isActive == true
// uddate AppStorage
subscribed = isProUser
print("isProUser: \(isProUser)")
} catch {
print(error.localizedDescription)
}
}
This is my solution:
.sheet(isPresented: $displayPaywall,
onDismiss: {
Task {
do {
let customerInfo = try await Purchases.shared.customerInfo()
isProUser = customerInfo.entitlementss"Pro"]?.isActive == true
// update AppStorage
subscribed = isProUser
print("isProUser: \(isProUser)")
} catch {
print(error.localizedDescription)
}
}
}) {
PaywallView(displayCloseButton: true)
}
@Tim Mitra I had the EXACT same question. This answer is how I’m doing to do it with PaywallView.
If the documentation on this page was updated it would really help. For the “custom logic” example it shows a purchaseCompleted completion handler you can use. However, it’s not clear at all how to do that with the “manually” example. From that other thread I learned you can use .onPurchaseCompleted .
I’m attempting to use .onPurchaseCompleted but don’t see it called after PaywallView is dismissed.
.sheet(isPresented: self.$displayPaywall) {
PaywallView(displayCloseButton: true)
}
.onPurchaseCompleted { customerInfo in
print("purchase completed")
isSubscribed = customerInfo.entitlementst"pro"]?.isActive == true
}
What is wrong or missing?
Anyone could help here? Thanks.