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.
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.
Register SwiftUI windows
Apply .btxMessenger() once to each SwiftUI window's root view after configuration.
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.
Register AppKit windows
Attach after creating the window and assigning its content view.
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).