Configure the SDK by chaining CollectOption() builder methods, then call .build() to produce the Option you pass to Collect.initialize(option:).
let collectOptions = CollectOption()
.writeKey(value: "YOUR_WRITE_KEY")
.useConsent(value: true)
.checkForCMP(value: true)
.hashIdentities(value: true)
.userCountry(code: "DEU")
.build()
Collect.initialize(option: collectOptions)
Core options
| Method | Type | Default | Description |
|---|
writeKey(value: String) | String | — | Write key from the iOS Source. |
logging(value: Bool) | Bool | false | If true, displays info / debug / warning / error logs. Otherwise only warning + error. |
optOut(value: Bool) | Bool | false | Master kill switch. If true, no events are posted to SPL. Used as a fallback when consent is not used. |
Consent
| Method | Type | Default | Description |
|---|
useConsent(value: Bool) | Bool | false | If true, the SDK waits for a consent signal before recording events. |
checkForCMP(value: Bool) | Bool | false | If true (with useConsent), the SDK reads the TCF 2.0 CMP data stored by other CMPs to manage consent. |
checkZeotapVendorConsent(value: Bool) | Bool | false | If true, the SDK requires Zeotap Vendor consent when resolving GDPR consent. If false, Zeotap Vendor consent is ignored. |
purposesForTracking(value: [Int]) | [Int] | [1, 3, 4] | TCF purpose IDs that gate tracking. See the TCF policies appendix. |
purposesForIdentifying(value: [Int]) | [Int] | [1, 9] | TCF purpose IDs that gate identification. |
For the full consent walkthrough see Consent Resolution.
Identity & hashing
| Method | Type | Default | Description |
|---|
areIdentitiesHashed(value: Bool) | Bool | false | Set true if your setUserIdentities calls already supply hashed PII keys (email_sha256_lowercase, etc.). |
hashIdentities(value: Bool) | Bool | false | If true, raw PII passed to setUserIdentities is hashed by the SDK before being sent. |
Both flags apply only to PII fields. Custom identities (crmID, visitorID, etc.) are always sent as-is.
Event delivery
| Method | Type | Default | Description |
|---|
batchSize(value: Int) | Int | 30 | Maximum events allowed in the unsent queue before the next batch dispatches immediately. |
maxCacheSize(value: Int) | Int | 100 | Maximum events stored in local memory during network failures or delayed consent. Max value 200. |
eventUploadInterval(value: Int) | Int | 90 | If the queue is below the batch threshold, the next dispatch is scheduled after this many seconds. |
Region
| Method | Type | Default | Description |
|---|
userCountry(code: String) | String | nil | Alpha-ISO3 country code sent as user.user_country. Determines storage region. Defaults to IP-derived country when omitted. |
A complete example
let collectOptions = CollectOption()
.writeKey(value: "YOUR_WRITE_KEY")
.logging(value: false)
.useConsent(value: true)
.checkForCMP(value: false) // custom consent flow
.hashIdentities(value: true)
.areIdentitiesHashed(value: false)
.batchSize(value: 30)
.maxCacheSize(value: 100)
.eventUploadInterval(value: 90)
.userCountry(code: "DEU")
.purposesForTracking(value: [1, 3, 4])
.purposesForIdentifying(value: [1, 9])
.build()
Collect.initialize(option: collectOptions)