iOS SDK

Configuration

Initialize the SDK with your API key and environment settings

Configuration

Initialize the SDK at app launch with your API key and configuration options. Call setup(with:) once, as early as possible -- typically in your AppDelegate.application(_:didFinishLaunchingWithOptions:) or your SwiftUI App.init().

Minimal setup

swift
import Nuxie
 
let config = NuxieConfiguration(apiKey: "your_api_key")
try NuxieSDK.shared.setup(with: config)

Find your API key in the Nuxie dashboard under Settings > API Keys.

The SDK is ready to use after setup(with:) returns. Behind the scenes, it starts asynchronous tasks to fetch your profile, initialize the event system, and begin listening for StoreKit transactions.

Full setup example

swift
import Nuxie
 
let config = NuxieConfiguration(apiKey: "your_api_key")
 
// Environment
config.environment = .production
 
// Logging
config.logLevel = .debug
config.enableConsoleLogging = true
config.redactSensitiveData = true
 
// Event batching
config.flushAt = 20
config.flushInterval = 30
config.maxQueueSize = 1000
 
// Identity
config.eventLinkingPolicy = .migrateOnIdentify
 
// Locale override
config.localeIdentifier = "es_ES"
 
// Privacy
config.propertiesSanitizer = DefaultPropertiesSanitizers.privacy
config.beforeSend = { event in
    // Drop internal debug events
    if event.name.hasPrefix("debug_") { return nil }
    return event
}
 
// Purchases
config.purchaseDelegate = MyPurchaseDelegate()
 
try NuxieSDK.shared.setup(with: config)

Configuration options

Core

PropertyTypeDefaultDescription
apiKeyStringRequiredYour Nuxie API key.
environmentEnvironment.productionTarget environment. Changing this updates apiEndpoint automatically unless you set a custom endpoint.
apiEndpointURLhttps://i.nuxie.ioOverride the API endpoint for custom deployments.
isDebugModeBoolfalseBypass caches for flow and profile fetches during development.

Environments

EnvironmentEndpoint
.productionhttps://i.nuxie.io
.staginghttps://staging-i.nuxie.io
.developmenthttps://dev-i.nuxie.io
.customSet apiEndpoint manually.

Logging

PropertyTypeDefaultDescription
logLevelLogLevel.warningMinimum log level. Options: .verbose, .debug, .info, .warning, .error, .none.
enableConsoleLoggingBooltruePrint log output to the console.
enableFileLoggingBoolfalseWrite logs to a file on disk.
redactSensitiveDataBooltrueMask API keys and distinct IDs in log output.

Event batching

PropertyTypeDefaultDescription
eventBatchSizeInt50Maximum events per network batch.
flushAtInt20Number of queued events that triggers an automatic flush.
flushIntervalTimeInterval30Seconds between automatic flushes.
maxQueueSizeInt1000Maximum events held in the network queue. Oldest events are dropped when full.

Identity

PropertyTypeDefaultDescription
eventLinkingPolicyEventLinkingPolicy.migrateOnIdentifyControls whether locally stored events are reassigned from the anonymous ID to the identified ID on identify(). Options: .migrateOnIdentify, .keepSeparate.

Locale

PropertyTypeDefaultDescription
localeIdentifierString?nilOverride the device locale for profile requests (e.g., "es_ES"). When nil, the SDK uses Locale.current.identifier. Call refreshProfile() after changing this value.

Privacy

PropertyTypeDefaultDescription
propertiesSanitizerNuxiePropertiesSanitizer?nilA custom sanitizer applied to event properties before storage and delivery. The SDK includes built-in sanitizers: DefaultPropertiesSanitizers.privacy, .compliance, and .debug.
beforeSend((NuxieEvent) -> NuxieEvent?)?nilA hook called before each event is stored and sent. Return nil to drop the event entirely, or return a modified event.

Purchases

PropertyTypeDefaultDescription
purchaseDelegateNuxiePurchaseDelegate?nilHandles purchase and restore requests from flows. Required if your flows contain purchase actions. See Purchases.

Plugins

PropertyTypeDefaultDescription
enablePluginsBooltrueEnable the plugin system.
plugins[NuxiePlugin][AppLifecyclePlugin()]Plugins installed during setup. The AppLifecyclePlugin is included by default and tracks $app_installed, $app_updated, $app_opened, and $app_backgrounded.

Setup behavior

When you call setup(with:), the SDK performs these steps synchronously:

  1. Validates the API key.
  2. Registers the configuration.
  3. Configures the logger.
  4. Starts the app lifecycle coordinator.
  5. Installs and starts plugins (if enabled).

It also launches background tasks for:

  • Initializing the event storage and network queue.
  • Restoring persisted campaign journeys.
  • Fetching the initial profile from the edge.
  • Syncing feature access to the SwiftUI observable.
  • Listening for StoreKit 2 transaction updates.

Tip: setup(with:) is intentionally one-shot. Calling it a second time logs a warning and returns without reconfiguring. If you need to change configuration, restart the app with the new settings.

Next steps