getCustomerInfo
Gets the latest CustomerInfo asynchronously.
This method was introduced in version 4.10.0. It provides an async way to get the latest customer information.
Purpose
Retrieves the latest CustomerInfo asynchronously. If customer info is already available, it returns immediately. Otherwise, it waits for the first non-placeholder customer info to be loaded.
Signature
public func getCustomerInfo() async -> CustomerInfo
public func getCustomerInfo(completion: @escaping (CustomerInfo) -> Void)Parameters
No parameters for the async version. The completion handler version takes a completion closure.
Returns / State
Returns a CustomerInfo object containing the latest customer purchase and subscription data.
Usage
Using async/await:
let customerInfo = await Superwall.shared.getCustomerInfo()
// Use the customer info
print("User has \(customerInfo.subscriptions.count) subscriptions")
print("Active product IDs: \(customerInfo.activeSubscriptionProductIds)")Using completion handler:
Superwall.shared.getCustomerInfo { customerInfo in
// Handle customer info
print("User has \(customerInfo.subscriptions.count) subscriptions")
// Update UI on main thread
DispatchQueue.main.async {
self.updatePurchaseHistory(customerInfo)
}
}In a Task:
Task {
let customerInfo = await Superwall.shared.getCustomerInfo()
// Process customer info
await processCustomerInfo(customerInfo)
}Related
customerInfo- Published property for customer infocustomerInfoStream- AsyncStream of customer info changescustomerInfoDidChange(from:to:)- Delegate method for customer info changes
How is this guide?
Edit on GitHub