Skip to main content
Registers a handler invoked for all not-granted outcomes — when the user dismisses the offer or no offers are available. This signals “Encore didn’t result in a purchase — run your original button logic.”
Set onPassthrough before calling placement().show(). If not set, the SDK will log a warning.

Signature

public func onPassthrough(_ handler: @escaping (_ placementId: String) -> Void)

Parameters

NameTypeDescription
handler(String) -> VoidCallback receiving the placementId. Execute your original button logic here.

Returns

Returns the Encore instance for chaining.

When It Fires

ScenarioFires?
User dismisses without purchasingYes
No offer available for this userYes
Network or system errorYes
User accepts an offerNo — see onPurchaseRequest()

Usage

Cancel flow passthrough

Encore.shared.onPassthrough { placementId in
    // Encore didn't intercept — proceed with original action
    switch placementId {
    case "cancel_flow":
        proceedWithCancellation()
    case "downgrade_flow":
        proceedWithDowngrade()
    default:
        print("Passthrough for \(placementId)")
    }
}

Chained with onPurchaseRequest

Encore.shared
    .onPurchaseRequest { productId, placementId in
        guard let product = try await Product.products(for: [productId]).first else { return }
        let result = try await product.purchase()
    }
    .onPassthrough { placementId in
        proceedWithCancellation()
    }
Use onPassthrough to ensure your original button logic still runs when Encore doesn’t intercept. For example, if a user taps “Cancel Subscription” and Encore has no offers, the passthrough handler lets you proceed with the cancellation flow.