Nx10 Logo
Docs

1. Initialization

Configure the SDK, enable consent-controlled networking, and start a backend session.

Startup happens in two steps. First, call configure synchronously with your API key and App Group. Then enable data collection and call startSession(for:) to complete the asynchronous handshake with nx10. That handshake downloads the device configuration used by telemetry, BrainJuice, games, analytics, and SaaQ prompts.

Networking is off by default. startSession(for:) and later uploads will fail until data-collection consent is enabled.

YourApp.swift
import SwiftUI
import NX10CoreSDK

@main
struct YourApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate

    init() {
        do {
            try NX10Core.shared.configure(
                NX10CoreConfig(
                    apiKey: "YOUR_API_KEY",
                    appGroup: "group.your.app.identifier",
                    errorTrackingEnabled: true,
                    enableDebug: false
                )
            )
        } catch {
            print("NX10CoreSDK configuration failed: (error)")
        }

        Task {
            NX10Core.shared.consent.allowDataCollection = true
            _ = try? await NX10Core.shared.startSession(enableDemo: false)
        }
    }

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

Configuration Parameters

Required
  • apiKey: your project API key.
  • appGroup: the shared App Group identifier.
Optional
  • errorTrackingEnabled: enables SDK diagnostics.
  • enableDebug: enables verbose logging and staging endpoints.

SceneDelegate Setup

The recommended route is to subclass NX10MESceneDelegate. It installs the touch-interceptor window required for touch telemetry and wires SaaQ prompt presentation without an extra root-view modifier.

SceneDelegate.swift
import SwiftUI
import NX10CoreSDK

class SceneDelegate: NX10MESceneDelegate {
    override var contentView: AnyView {
        AnyView(ContentView())
    }
}
AppDelegate.swift
import UIKit

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        configurationForConnecting connectingSceneSession: UISceneSession,
        options: UIScene.ConnectionOptions
    ) -> UISceneConfiguration {
        let sceneConfig = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
        sceneConfig.delegateClass = SceneDelegate.self
        return sceneConfig
    }
}

Keyboard Extension Setup

Keyboard extensions configure the SDK from UIInputViewController because they do not use a scene delegate. The App Group must match the host app.

KeyboardViewController.swift
import UIKit
import NX10CoreSDK

class KeyboardViewController: UIInputViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        Task {
            do {
                try NX10Core.shared.configure(
                    NX10CoreConfig(
                        apiKey: "YOUR_API_KEY",
                        appGroup: "group.your.app.identifier",
                        errorTrackingEnabled: true,
                        enableDebug: false
                    )
                )
                NX10Core.shared.consent.allowDataCollection = true
                _ = try await NX10Core.shared.startSession(for: false)
            } catch {
                print("NX10CoreSDK keyboard configuration failed: (error)")
            }
        }
    }
}