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
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() }
}
}func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Nabd.start(NabdConfig(orgToken: AppSecrets.nabdKey, appName: "My App"))
return true
}Consent
Nabd.setConsent(true)Screen names
InvoiceCreateView()
.nabdScreen("invoice_create")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
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
// 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
- Rage taps, and taps on a disabled UIKit element.
NSExceptionexceptions (type and fingerprint), and unexpected exits (estimated, sent on the next launch, including Swift crashes).
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.
Nabd.start(NabdConfig(orgToken: AppSecrets.nabdKey, appName: "My App", messages: true))// 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()- The app checks for messages when it opens or returns to the foreground, every two minutes, and every 15 seconds while the conversation is open. There is no notification while the app is closed.
- The interface is Arabic if the app language (the first preferred bundle localization) is Arabic, and English otherwise.
- The conversation and its taps are not counted as usage signals.
- The conversation is tied to this installation by a random secret stored on the device; another device of the same user does not see it, and a data deletion request changes the secret.
- Compute
user_refwith HMAC on your server, so a user cannot pretend to be someone else. - The floating button may cover part of your UI at the bottom.
- The package’s Privacy Manifest does not declare customer support content yet; if you enable chat, add it to your app’s disclosure.
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
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.