Skip to main content

Overview

Encore allows you to present targeted offers to users in exchange for rewards (free trials, discounts, credits) at critical moments like cancellation flows or feature paywalls. The SDK uses a delegation pattern — you register purchase and passthrough handlers, then call .show() wherever you need an offer.

Present Offers

Presenting an Encore offer is a single line:
Button("Cancel Subscription") {
    Encore.placement("cancellation_flow").show()
}
Important: When presenting offers in critical flows (like cancellation), your onPassthrough handler ensures users are never blocked from completing their intended action.
Register handlers before presenting. See Handle Offer Results below.

Handle Offer Results

Register handlers that tell the SDK how to complete purchases and what to do when a user dismisses. Register these once at app launch, after configure().

Register onPurchaseRequest

Called when a user accepts an offer. Use this to trigger a purchase via StoreKit, RevenueCat, Adapty, or your own billing implementation.
Encore.shared.onPurchaseRequest { purchaseRequest in
    guard let product = try await Product.products(for: [purchaseRequest.productId]).first else { return }
    let result = try await product.purchase()
}
The example above uses StoreKit 2. See onPurchaseRequest() for RevenueCat, Adapty, Qonversion, and custom subscription manager examples.

Register onPassthrough

Called when the user dismisses the offer or no offers are available. Use this to resume the user’s original action (e.g., proceed with cancellation).
Encore.shared.onPassthrough { placementId in
    // Resume your original user flow
}

onPurchaseComplete (Optional)

Only needed when you don’t set an onPurchaseRequest handler, or when integrating with subscription managers that don’t auto-detect purchases (e.g., Adapty, Qonversion). RevenueCat and Superwall auto-detect purchases and don’t need this callback.
Encore.shared.onPurchaseComplete { productId, placementId in
    // Sync purchase state with your subscription manager
}

Summary

CallbackWhen it firesRequired?
onPurchaseRequestUser accepts the offerYes
onPassthroughUser dismisses or no offers availableYes
onPurchaseCompletePurchase finishes (for managers that don’t auto-detect)Optional
Both onPurchaseRequest and onPassthrough must be registered before presenting any placements.

Third-Party Paywall Integrations

For Superwall and RevenueCat integrations, see the dedicated guides:

Using Superwall

Trigger Encore from Superwall paywalls and dismissals

Using RevenueCat

Trigger Encore from RevenueCat paywalls and dismissals

Next Steps