Swift SDK Configuration Options Reference

Complete reference for the configuration options available in the RudderStack Swift SDK.

The RudderStack Swift SDK provides various configuration options to customize its behavior according to your requirements. This guide covers all the available configuration options and their usage.

Configuration class

The Configuration class is used to initialize the SDK in your Apple platform application. It defines the required parameters and optional configuration settings to customize the SDK behavior.

SDK configuration options

ParameterTypeDescription
writeKey
Required
StringThe source write key obtained from the RudderStack dashboard used for authentication.
dataPlaneUrl
Required
StringThe URL of your RudderStack data plane (backend) where the events are sent.
controlPlaneUrlStringURL for remote configuration management.

Default value: https://api.rudderlabs.com
gzipEnabledBooleanEnables or disables Gzip compression for network requests.

Default value: false
flushPoliciesArray of flush policiesSpecifies when and how events are sent to the RudderStack backend.

See Flush policies in Swift SDK for more information.

Default value: [StartupFlushPolicy(), FrequencyFlushPolicy(), CountFlushPolicy()]
collectDeviceIdBooleanEnables automatic collection of the device’s unique ID.

Default value: true
trackApplicationLifecycleEventsBooleanEnables automatic tracking of application lifecycle events (app start, background, and foreground transitions).

Default value: true
sessionConfigurationSessionConfigurationConfiguration settings for managing user sessions.

  • See Session Tracking for more information on session management in the Swift SDK.
  • See Session configuration for more information on the session configuration options and their default values.

Session configuration

The SessionConfiguration class provides the following parameters to customize session management:

ParameterTypeDescription
automaticSessionTrackingBooleanEnables automatic session tracking.

Default value: true
sessionTimeoutInMillisUInt64Sets the timeout duration for automatic session tracking in milliseconds. It is the time between the app closed or backgrounded to being foregrounded or relaunched again.

The SDK times out a session and starts a new session after this time has elapsed.

Default value: 300000 (5 minutes)

Device ID collection

When you enable collectDeviceId, the SDK retrieves a unique device ID and includes it in the event payload under the device.id field in the event’s context object.

In the iOS, watchOS, and tvOS platforms, the SDK uses the device’s identifierForVendor field. In macOS, it derives the ID from the device’s MAC address.

warning
If the SDK retrieves an empty or invalid value for the device ID, it will not include the device.id field in the event payload’s context.

Request compression

When you set gzipEnabled to true, all /batch requests sent by the SDK will have their payloads compressed using Gzip compression, thereby reducing the size of the network requests.

Sample SDK initialization

The following snippet demonstrates how to initialize the Swift SDK with the supported configuration options:


Questions? Contact us by email or on Slack