PurchaseController
A protocol for handling Superwall's subscription-related logic with your own purchase implementation.
This protocol is not required. By default, Superwall handles all subscription-related logic automatically.
When implementing PurchaseController, you must manually update subscriptionStatus
whenever the user's entitlements change.
Purpose
Use this protocol only if you want complete control over purchase handling, such as when using RevenueCat or other third-party purchase frameworks.
Signature
Parameters
Method | Parameters | Return Type | Description |
---|---|---|---|
purchase | product: StoreProduct | PurchaseResult | Called when user initiates purchasing. Implement your purchase logic here. |
restorePurchases | None | RestorationResult | Called when user initiates restore. Implement your restore logic here. |
Returns / State
purchase()
returns aPurchaseResult
(.purchased
,.failed(Error)
, or.cancelled
)restorePurchases()
returns aRestorationResult
(.restored
or.failed(Error?)
)
When using a PurchaseController, you must also manage subscriptionStatus
yourself.
Usage
For implementation examples and detailed guidance, see Using RevenueCat.
This is commonly used with RevenueCat, StoreKit 2, or other third-party purchase frameworks where you want to maintain your existing purchase logic.
How is this guide?