> ## 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 Adapty

> Integrate Encore with Adapty for subscription management

## Overview

Encore works alongside Adapty so you can present retention offers at key moments in your app. Since Adapty doesn't include a built-in paywall component, you present Encore offers directly using `Encore.placement().show()`.

<Info>
  Adapty handles subscription management, analytics, and attribution. Encore handles retention offer presentation and purchase delegation.
</Info>

***

## Handle Offer Results

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

### Register `onPurchaseRequest`

```swift theme={null}
Encore.shared.onPurchaseRequest { purchaseRequest in
    let products = try await Adapty.getPaywallProducts(paywall: paywall)
    guard let product = products.first(where: { $0.vendorProductId == purchaseRequest.productId }) else { return }
    try await Adapty.makePurchase(product: product)
}
```

<Tip>
  See [onPurchaseRequest()](../sdk-reference/on-purchase-request) for complete API details and examples with other subscription managers.
</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. You must manually report each transaction to Adapty so it can track entitlements.

### Setup

1. Configure Adapty SDK in observer mode:

```swift theme={null}
try await Adapty.activate(with: .builder(withAPIKey: "YOUR_KEY")
    .with(observerMode: true)
    .build()
)
```

2. Register `onPurchaseComplete` to report transactions:

```swift theme={null}
Encore.shared.onPurchaseComplete { transaction, productId in
    try? await Adapty.reportTransaction(transaction)
}
```

<Note>
  Adapty SDK 3.3+ in observer mode requires manual `reportTransaction()` calls for StoreKit 2 transactions.
</Note>

***

## Configure Analytics

### Encore Webhook

Encore uses Apple's App Store Server Notifications to track subscription lifecycle events and measure offer impact. See [Configure Analytics](../quickstart/configure-analytics) for full setup instructions.

<Info>
  If Adapty already occupies your primary App Store Server Notifications URL, use the **Forward from Your Server** option to send notifications to both Adapty and Encore.
</Info>

### Adapty Webhook

If you're using the [Automatic StoreKit Purchase](#alternative-automatic-storekit-purchase) approach above, Adapty also needs to receive App Store Server Notifications to track renewals and refunds.

In App Store Connect, add the ASSN V2 webhook URL from your **Adapty Dashboard**. If Encore is your primary URL, forward notifications to Adapty from your server.
