Skip to main content

Overview

As soon as your app launches, you need to configure the SDK with your API Key. Retrieve your publishable Live key yourself from the Dashboard under Settings → Project API Keys (use the Test key for staging and local development).

Initialize Encore in Your App

Edit your main App struct to configure Encore at launch:
This configures a shared instance of Encore, the primary class for interacting with the SDK’s API. Make sure to replace pk_live_your_key with your publishable API key.

Register a Purchase Controller

If your app sells a subscription product through Encore offers, register an EncorePurchaseController at configure time. The SDK has no built-in billing: when a user accepts an offer that requires a purchase, the SDK calls your controller, which performs the purchase through your billing code and reports back.
See Presenting Offers for a StoreKit 2 controller implementation, and EncorePurchaseController for RevenueCat, Adapty, and custom variants. Apps that use Encore offers without anything to unlock can skip the controller: with no product configured, no purchase is ever attempted.
Can’t find your API key? Open your project’s Settings → Project API Keys in the Encore Dashboard and copy the Live key pk_live_… (or the Test key pk_test_… for non-production builds).

Options: Logging and Unlock Mode

configure(apiKey:purchaseController:options:) accepts an Options value for runtime behavior:
Both options have safe defaults (logLevel: .none, unlock: .optimistic). See configure() for the full contract and EntitlementScope for the two-phase grant model.

Next Steps

Now that Encore is configured, you’re ready to: