Skip to content
Configuration

Configure BTX for macOS

Configure BTX and register each SwiftUI or AppKit host window.

Configure once

Call BTX.configure(...) on the main actor during app startup, before identifying a customer. For push integration, configure before the app finishes launching.

App startup
import BTXClientKit

@MainActor
func configureBTX() {
    BTX.configure(
        BTXConfiguration(
            publishableClientKey: "cfk_...",
            features: [.messenger],
            messengerOptions: BTXMessengerOptions(
                title: "Support",
                teamDisplayName: "Acme Support",
                appName: "Acme"
            )
        )
    )
}

The default feature set enables .messenger. Add .logs to the feature set to send product telemetry.

Use a macOS publishable client key. Keep server credentials and APNs private keys out of the app bundle.

01

Register SwiftUI windows

Apply .btxMessenger() once to each SwiftUI window's root view after configuration.

SwiftUI app
import SwiftUI
import BTXClientKit

@main
@MainActor
struct AcmeApp: App {
    init() {
        configureBTX()
    }

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

Replace ContentView with your app's root view. Call BTX.identify(...) when the signed-in customer is available.

02

Register AppKit windows

Attach after creating the window and assigning its content view.

AppKit window setup
import AppKit
import BTXClientKit

@MainActor
func attachSupport(to window: NSWindow) {
    BTX.messenger.attach(to: window)
}

For apps with multiple windows, register each window that can host support. If no registered window is available, presentation returns .failed(.unavailable).