Skip to main content
Configures the shared Encore instance for use throughout your app. This must be called once, typically in your AppDelegate or SwiftUI App initializer, before using any other SDK methods.
Call configure() before using any other SDK methods. Failure to do so produces EncoreError.integration(.notConfigured) errors.

Signature

Options bundles the SDK’s runtime settings:
The older configure(apiKey:logLevel:unlock:) overload is deprecated — it forwards to configure(apiKey:options:). Prefer passing an Options value.

Parameters

NameTypeDefaultDescription
apiKeyString-Your Live Key (pk_live_…) or Test Key (pk_test_…) from the Encore Dashboard
optionsEncore.Options.init()Runtime options — log verbosity and unlock mode

Options

FieldTypeDefaultDescription
logLevelEncore.LogLevel.noneLogging verbosity
unlockUnlockMode.optimisticWhen entitlements are granted after an offer flow

Unlock mode

UnlockMode controls when the SDK grants an entitlement after the user returns from an offer:
ModeBehaviorUse when
.optimistic (default)Grants the moment the user returns to the app. This is the provisional grant — instant UX, later confirmed (or revoked) by the backend.You want the snappiest unlock and gate reversible UX on the .all scope (see EntitlementScope).
.strictWithholds the grant until the advertiser’s postback verifies the conversion.You only ever want verified grants and can tolerate a short delay before the reward appears.

Log levels

Higher levels include all lower levels. For example, .info will also show warnings and errors.

API keys

Encore supports two types of API keys:
Key TypeFormatDescription
Live Keypk_live_...Production key with standard geo-filtering based on offers’ configured regions
Test Keypk_test_...Testing key that bypasses geo-filtering, allowing you to test the complete entitlement lifecycle from any location
Use the test key (pk_test_...) during development to test offers from any location without geo-filtering restrictions. This makes it easy to test the entire entitlement lifecycle end-to-end for a single user.
Always use your live key (pk_live_...) in production builds. The test key is for development and testing only.

Usage

Basic Configuration

SwiftUI

With Debug Logging (Development)

Using Test Key for Development

Use the test key to test offers from any location without geo-filtering:
The test key (pk_test_...) is perfect for comprehensive end-to-end testing of the entitlement lifecycle, allowing you to test location-restricted offers from anywhere during development.
Use logLevel: .debug during development to see detailed SDK logs, then remove it (or use .none) for production builds.