iOS (Swift) In development

NabdSDK as a Swift Package for apps on iOS 15 and later.

Not available yet. These examples show the planned API; package and function names may change before the first release.

Install

In Xcode: File ▸ Add Package Dependencies, then choose NabdSDK. The package URL will be announced with the first release.

Setup

SwiftUI
import SwiftUI
import NabdSDK

@main
struct MyApp: App {
    init() {
        Nabd.start(NabdConfig(
            orgToken: AppSecrets.nabdKey,
            appName: "My App",
            environment: .production,
            consentRequired: true
        ))
    }

    var body: some Scene {
        WindowGroup { ContentView() }
    }
}
UIKit — AppDelegate
func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
    Nabd.start(NabdConfig(orgToken: AppSecrets.nabdKey, appName: "My App"))
    return true
}
swift
Nabd.setConsent(true)

Screen names

SwiftUI
InvoiceCreateView()
    .nabdScreen("invoice_create")
UIKit
final class InvoiceViewController: UIViewController, NabdScreenNaming {
    var nabdScreen: String { "invoice_create" }
}

UIKit screens in your own app code are captured automatically by class name. SwiftUI screens need .nabdScreen.

Manual events

swift
Nabd.track(.taskCompleted, screen: "invoice_create")
Nabd.startLoading("invoice_create")
Nabd.stopLoading("invoice_create")
Nabd.setUserRef(userRefFromServer)

// an error you caught: type and fingerprint only
Nabd.captureError(error)

Network

URLSession
// for a whole session
let session = URLSession(configuration: .default,
                         delegate: NabdURLSessionDelegate(), delegateQueue: nil)

// or for one request
let (data, response) = try await URLSession.shared.data(
    for: request, delegate: NabdURLSessionDelegate())

Status and duration only. If your session has its own delegate, record errors with Nabd.captureError.

Captured automatically

With every error or unexpected exit, the last 10 steps. Turn it off with errorTrail: false.

Detection limits: disabled SwiftUI buttons are not detected, most SwiftUI buttons appear in the trail as “list row” or “another element”, and Swift errors you catch in code need captureError.

Support chat

With messages, your team can message a specific user from a ticket in the dashboard, and the user replies inside the app. Off by default; the floating button appears only when there is a message for them, after consent. You need setUserRef to open a ticket for them.

swift
Nabd.start(NabdConfig(orgToken: AppSecrets.nabdKey, appName: "My App", messages: true))
With your own UI
// with messagesUI: false in NabdConfig
let stop = Nabd.onMessages { conversations in render(conversations) }
Nabd.watchMessages(true) // while the conversation is open
Nabd.replyToMessage(conversationId, text: text) { sent in }
Nabd.markMessagesRead(conversationId)
stop()

Message text is stored in Nabd for the retention period. Tell your users in your privacy policy, and add “Customer Support” to your App Store and Google Play disclosures.

Privacy

swift
AmountKeypad().nabdIgnore()   // SwiftUI
Nabd.ignore(keypadView)       // UIKit
Nabd.requestDataDeletion()
Nabd.setConsent(false)

The package includes a Privacy Manifest. Review your App Privacy answers in App Store Connect. No IDFA and no tracking prompt.