refreshCustomerInfo
Fetch the user's latest entitlements from Superwall after your server reports a purchase, and get updated CustomerInfo with async/await or a completion handler.
refreshCustomerInfo() fetches entitlements from Superwall, even if they were fetched recently. Use it after your server reports a custom store purchase to make the updated access available in your app. Unlike getCustomerInfo(), it forces a server refresh.
Requirements
Available in SuperwallKit 4.19.0 and later. Configure Superwall before calling it. Your server must have reported the purchase to Superwall; this method does not query your billing provider.
Signature
@discardableResult
public func refreshCustomerInfo() async -> CustomerInfo
public func refreshCustomerInfo(completion: @escaping (CustomerInfo) -> Void)Prop
Type
Usage
After your server confirms it has reported the purchase:
let customerInfo = await Superwall.shared.refreshCustomerInfo()
print(customerInfo.entitlements)Or use a completion handler:
Superwall.shared.refreshCustomerInfo { customerInfo in
DispatchQueue.main.async {
self.updatePurchaseHistory(customerInfo)
}
}The fetched entitlements update customerInfo and entitlements. The SDK already refreshes entitlements in the background after a successful custom product purchase, including when your PurchaseController returns .purchased. Call this method if server reporting finishes later. Apps also refresh entitlements on foreground, including apps without web paywalls.
Limitations
- In SDK 4.19.1 and later, if the fetch fails, the method falls back to
getCustomerInfo(), allowing the device's purchases to load. If configuration also fails or the waiting task is cancelled, it returns the current value, which may be empty. It does not throw. A returned value alone does not confirm the server has granted access. - In Test Mode, it makes no request and returns the test mode customer info.
- A
PurchaseControllerremains responsible for managingsubscriptionStatus.
Related
How is this guide?