> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encorekit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Superwall

> Integrate Encore offers seamlessly with Superwall paywalls.

## Overview

Encore works alongside Superwall so you can present retention offers at key moments in your paywall flow.

***

## Presenting Offers

### Option 1: On Paywall Dismissal

Trigger Encore when a user dismisses your Superwall paywall without converting:

```swift theme={null}
import SuperwallKit
import Encore

class SWDelegate: SuperwallDelegate {
    func willDismissPaywall(withInfo paywallInfo: PaywallInfo) {
        // User dismissed without purchasing
        Encore.placement().show()
    }
}
```

***

### Option 2: Custom Paywall Action

Create/Update the Superwall delegate to handle custom actions from your paywall:

```swift theme={null}
import SuperwallKit
import Encore

class SWDelegate: SuperwallDelegate {
    func handleCustomPaywallAction(withName name: String) {
        if name == "EncoreTrigger" {
            Encore.placement("superwall_trigger").show()
        }
    }
}
```

Then, in the Superwall editor, add a custom action named "EncoreTrigger" to any button or element in your paywall.

<video className="w-full aspect-video rounded-xl" autoPlay loop muted playsInline src="https://storage.googleapis.com/yaw-assets/website/Superwall%20Demo.mp4" />

<Tip>
  See the SDK Reference for complete API details: [placement()](../sdk-reference/placement)
</Tip>

***

## Handle Offer Results

Register handlers at app launch so Encore can delegate purchases to Superwall.

### Register `onPurchaseRequest`

```swift theme={null}
Encore.shared.onPurchaseRequest { purchaseRequest in
    guard let product = try await Product.products(for: [purchaseRequest.productId]).first else {
        return false
    }
    let result = try await product.purchase()
    if case .success = result { return true }   // dismisses the offer sheet
    return false
}
```

<Tip>
  See [onPurchaseRequest()](../sdk-reference/on-purchase-request) for RevenueCat, Adapty, and other subscription manager examples. Return `true` on a successful purchase so Encore auto-dismisses the sheet.
</Tip>

### Register `onPassthrough`

Called when the user dismisses the offer or no offers are available. Use this to resume the user's original action.

```swift theme={null}
Encore.shared.onPassthrough { placementId in
    // Resume your original user flow
}
```

***

## Alternative: Automatic StoreKit Purchase

If you don't set `onPurchaseRequest`, Encore purchases via native StoreKit 2 automatically. Superwall can observe these transactions automatically.

### Setup

1. Configure Superwall to observe purchases:

```swift theme={null}
let options = SuperwallOptions()
options.shouldObservePurchases = true
Superwall.configure(apiKey: "YOUR_SW_KEY", options: options)
```

<Warning>
  Observer mode requires iOS 17.2+ and disables `Superwall.shared.purchase()`. Purchases go through StoreKit directly.
</Warning>

<Note>
  No `onPurchaseComplete` handler is needed — Superwall auto-detects StoreKit transactions in observer mode.
</Note>

***

## Configure Analytics

### Forward subscription events from Superwall to Encore

Configure Superwall to forward subscription events to Encore. In your Superwall dashboard:

1. Go to **Integrations -> Webhooks -> Create**
2. URL: `https://api.encorekit.com/encore/webhooks/superwall/<your-token>` (your token is provisioned by Encore — see the note below)
3. Copy the signing secret from Superwall and share it securely with Encore (used for HMAC verification on inbound events)

Superwall will POST subscription events to Encore via Svix-signed requests. This powers offer impact measurement.

<Note>
  Your Superwall webhook token (a `swl_…` value) is issued by Encore and surfaced in your dashboard. Unlike your SDK API keys — which you retrieve yourself — this third-party webhook token is provisioned during onboarding, so share your Superwall project details with Encore to receive it.
</Note>

<Tip>
  **Custom server infrastructure?** If you already operate your own ASSN proxy that fans out to multiple destinations, you can forward to Encore from there instead. This is an obsolete fallback — the webhook approach above is preferred for all new integrations.
</Tip>
