iOS SDK

iOS SDK - Configuration

Configure the Pricist iOS SDK.

Basic configuration

The only required value is your publishable SDK key (pk_live_…), found in the dashboard under Settings → SDK key:

import Pricist
 
let config = PricistConfiguration(sdkKey: "pk_live_…")
Pricist.shared.initialize(with: config)

SwiftUI app

Initialize early in the app lifecycle — in your App init or AppDelegate:

import SwiftUI
import Pricist
 
@main
struct MyApp: App {
    init() {
        Pricist.shared.initialize(with: PricistConfiguration(sdkKey: "pk_live_…"))
    }
 
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Full configuration with the builder

PricistConfiguration exposes chainable .with(…) builder methods:

let config = PricistConfiguration(sdkKey: "pk_live_…")
    .with(environment: "sandbox")         // "production" (default) or "sandbox"
    .with(logLevel: .debug)               // .none, .error, .warning, .info, .debug, .verbose
    .with(flushInterval: 30.0)            // auto-flush seconds (min 1.0, default 30.0)
    .with(maxBatchSize: 100)              // events drained per flush cycle (1–500)
    .with(host: "http://localhost:3000")  // override the API host for local dev
    .with(autoStart: false)               // defer start() until you have consent
    .with(waitForATTAuthorization: true)  // defer first flush until ATT is answered
 
Pricist.shared.initialize(with: config)
BuilderDefaultDescription
.with(environment:)"production""production" or "sandbox"
.with(logLevel:).none.none, .error, .warning, .info, .debug, .verbose
.with(flushInterval:)30.0Auto-flush interval in seconds (min 1.0)
.with(maxBatchSize:)100Events drained per flush cycle (1500)
.with(host:)https://api.pricist.devOverride the API host root
.with(autoStart:)trueWhen false, defers all activity until start()
.with(waitForATTAuthorization:)falseWhen true, defers the first flush until the ATT prompt resolves

autoStart and waitForATTAuthorization work with the consent and ATT APIs. See Privacy & Consent.

API host

By default the SDK calls https://api.pricist.dev and appends /api/track and /api/sdk/config. Pass host to point at a different origin — typically a webapp running on your dev machine. From the iOS simulator, localhost is the host machine:

let config = PricistConfiguration(sdkKey: "pk_test_…")
    .with(host: "http://localhost:3000")

Pass the host root only — no path, no trailing slash.

SDK control

// Disable all tracking (kill switch — for QA / debug; for GDPR use setConsent)
Pricist.shared.setEnabled(false)
 
// Re-enable tracking
Pricist.shared.setEnabled(true)
 
// Force-send queued events immediately
Pricist.shared.flush()

For GDPR / DMA / ATT, prefer setConsent(...) and requestTrackingAuthorization(...) over the kill switch — see Privacy & Consent.

Error handling

Errors are logged rather than thrown. Set logLevel to .debug to see validation errors in the console:

let config = PricistConfiguration(sdkKey: "pk_live_…")
    .with(logLevel: .debug)
 
Pricist.shared.initialize(with: config)

Error messages appear with the prefix [Pricist].