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 will result in .notInitialized errors.

Signature

public func configure(
  apiKey: String,
  logLevel: Encore.LogLevel = .none
)

Parameters

NameTypeDefaultDescription
apiKeyString-Your Live Key or Test Key from the Encore Dashboard settings
logLevelEncore.LogLevel?.noneLogging verbosity level

Log levels

public enum LogLevel: Int, Comparable {
  case none = 0    // No logging (recommended for production)
  case error = 1   // Only errors
  case warn = 2    // Warnings and errors
  case info = 3    // Milestones, warnings, and errors
  case debug = 4   // Everything (verbose, development only)
}
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

import Encore

func application(
  _ application: UIApplication,
  didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
  Encore.shared.configure(apiKey: "pk_your_api_key")
  return true
}

SwiftUI

@main
struct YourApp: App {
  init() {
    Encore.shared.configure(apiKey: "pk_your_api_key")
  }
  
  var body: some Scene {
    WindowGroup {
      ContentView()
    }
  }
}

With Debug Logging (Development)

#if DEBUG
Encore.shared.configure(
  apiKey: "pk_your_api_key",
  logLevel: .debug  // Enable debug logs for development
)
#else
Encore.shared.configure(apiKey: "pk_your_api_key")  // Silent for production
#endif

Using Test Key for Development

Use the test key to test offers from any location without geo-filtering:
#if DEBUG
Encore.shared.configure(
  apiKey: "pk_test_your_key",  // Bypasses geo-filtering
  logLevel: .debug
)
#else
Encore.shared.configure(apiKey: "pk_live_your_key")
#endif
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.