iOS SDK

iOS SDK - Remote Config

Read remote config values with the Pricist iOS SDK.

Remote Config lets you change values in your app without shipping a new build — flip features on or off, tune values, or drive paywall copy. Define keys in the Pricist dashboard and read them from the SDK at runtime.

The SDK fetches config on start(), caches the result for 5 minutes, and serves the cached snapshot offline. The synchronous getters work even before the network call completes (using cached or default values).

Reading values

The typed overload with a default is the recommended way to read values — it gives you compile-time type safety and a guaranteed fallback if the key is missing or the dashboard value is the wrong type:

let headline: String = Pricist.shared.getConfig("paywall_header", default: "Go Premium")
let maxRetries: Int = Pricist.shared.getConfig("max_retry_attempts", default: 3)
let showBanner: Bool = Pricist.shared.getConfig("show_banner", default: false)

There is also an untyped getter that returns Any?:

let raw = Pricist.shared.getConfig("paywall_header")

Reacting when config loads

To react the first time config arrives — for example, to render a paywall whose copy is configured remotely — register a callback:

Pricist.shared.onConfigLoaded { config in
    // config is [String: Any] with typed values (string / number / bool / json)
    let theme = Pricist.shared.getConfig("theme", default: "light")
    applyTheme(theme)
}

The callback fires immediately if config is already loaded (e.g. from cache), so you don't need to special-case the "already loaded" path.

Supported value types

Set values in the dashboard as string, number, boolean, or json. The SDK preserves these types — read them back as String, Int / Double, Bool, or [String: Any] / [Any]:

// JSON values come back as [String: Any]
if let flags = Pricist.shared.getConfig("feature_flags") as? [String: Any] {
    let aiEnabled = flags["ai_insights"] as? Bool ?? false
}

Caching behavior

LayerWhereTTL
In-memorySingleton stateProcess lifetime
DiskUserDefaults5 minutes
ServerPricist backendInvalidated on dashboard edits

On launch the SDK loads the cached snapshot synchronously, then fetches the latest in the background. Dashboard edits take effect on the server immediately, but devices may take up to 5 minutes to pick up changes because of the local cache.

Common patterns

Feature flags

if Pricist.shared.getConfig("new_checkout_enabled", default: false) {
    showNewCheckout()
} else {
    showLegacyCheckout()
}

Tuning values without a release

let timeoutMs: Int = Pricist.shared.getConfig("api_timeout_ms", default: 30_000)

Server-driven copy

welcomeLabel.text = Pricist.shared.getConfig("welcome_message", default: "Welcome!")