Registers a handler invoked when Encore’s offer flow completes and a purchase is needed. The handler receives aDocumentation Index
Fetch the complete documentation index at: https://docs.encorekit.com/llms.txt
Use this file to discover all available pages before exploring further.
PurchaseRequest containing the product ID, placement ID, and optional promotional offer ID. Use it to trigger the purchase via your subscription manager (e.g. StoreKit, RevenueCat).
Signature
Parameters
| Name | Type | Description |
|---|---|---|
handler | (PurchaseRequest) async throws -> Void | Async throwing callback receiving a PurchaseRequest. Trigger your purchase flow here. |
PurchaseRequest Properties
| Property | Type | Description |
|---|---|---|
productId | String | The App Store product identifier to purchase |
placementId | String? | Which placement triggered this purchase, if any |
promoOfferId | String? | Promotional offer identifier to apply, or nil for standard purchases |
Returns
Returns theEncore instance for chaining.
When It Fires
| Scenario | Fires? |
|---|---|
| User accepts an offer | Yes |
| User dismisses without purchasing | No — see onPassthrough() |
| No offer available for this user | No — see onPassthrough() |
Usage
- StoreKit
- RevenueCat
- Adapty
- Qonversion
- Custom
Chained with onPassthrough
The handler is an
async throws function, so you can call other async APIs (like StoreKit or network requests) directly inside it.When no
onPurchaseRequest handler is set, Encore handles purchases via native StoreKit 2 automatically.
Use onPurchaseComplete to sync these transactions with providers that don’t auto-detect StoreKit transactions (e.g., Adapty, Qonversion).