Skip to main content
As soon as your app launches, you need to configure the SDK with your API Key. You’ll receive your public API key from the Encore team to configure and identify your app.

Initialize Encore in Your App

Begin by editing your main application entry point. Depending on your app architecture, this could be your AppDelegate.swift for UIKit apps or your main App struct for SwiftUI apps.

SwiftUI

import SwiftUI
import Encore

@main
struct YourApp: App {
    init() {
        // Configure Encore with your API key
        Encore.shared.configure(apiKey: "pk_your_api_key_here")
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

UIKit

// AppDelegate.swift

import UIKit
import Encore

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // Configure Encore with your API key
        Encore.shared.configure(apiKey: "pk_your_api_key_here")
        return true
    }
}
This configures a shared instance of Encore, the primary class for interacting with the SDK’s API. Make sure to replace pk_your_api_key_here with your public API key.
If you don’t have access to your API key, please contact your Encore representative.

Next Steps

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