Skip to content
Identify customers

Identify macOS customers

Keep support, feedback, telemetry, and push registration tied to the signed-in customer.

Identify the signed-in customer

Call BTX.identify(...) on the main actor after authentication or session restoration. Use the same customer ID across launches and devices. Support, feedback, telemetry, and push registration share this identity.

Customer session
import BTXClientKit

@MainActor
func identifyBTXCustomer(id: String, name: String?, email: String?) {
    BTX.identify(
        BTXCustomer(externalID: id, name: name, email: email)
    )
}

Name and email are optional. BTXCustomer.phone is also optional; normalize phone numbers to E.164. Do not use access tokens or device identifiers as customer IDs.

01

Clear identity on sign-out

Before signing out or switching customers, unregister the push device while the current identity is still active. Await that operation before clearing identity or identifying the next customer.

Sign out
@MainActor
func clearBTXCustomer() async throws {
    try await BTX.messenger.unregisterPushDevice()
    BTX.identify(nil)
}

Handle a thrown unregister error in your sign-out flow and retry the unlink operation. Clearing identity alone does not confirm that the previous customer's push registration was removed from the server.