KontextAds.createSession(_:)
Session configured from the given SessionOptions. Fires /init in the background.
SessionOptions
Stable identifier for the end user. Used for personalization, frequency capping, and rewarded ads.
Privacy / consent signals. TCF (
gdpr / gdprConsent) is collected automatically if a TCF-compliant CMP is integrated — set manually only for COPPA, GPP, or US Privacy.IDFA you collected yourself. Takes priority over the SDK’s automatic collection. Use with
requestTrackingAuthorization: false.Session
Append a When
Message to the conversation. Synchronous. User messages trigger a debounced preload.trackOnly: true, the preload is sent for analytics but no ad is generated.Returns an
Ad for the given messageId. Idempotent — repeated calls with the same messageId + placement code return the same Ad. Cache the result.Live-update preload-scoped fields. See Guides → Live-updating session options.
Combine publisher delivering the same events as
onEvent. Useful for SwiftUI / Combine pipelines.true if the server has permanently disabled the session via the /init response (e.g. geo-restriction). Subsequent preloads are skipped.MutablePublisherOptions
Subset of SessionOptions accepted by session.updateOptions(_:). Every field is optional — non-nil overwrites, nil leaves unchanged.
Message
AdOptions
AddMessageOptions
When
true, the preload is still sent (for analytics) but no ad is generated for this message. Defaults to false.AdEvent
AdEvent is an enum with one typed payload per case. Every case has a stable string identifier accessible via event.name.
.filled(FilledData) — wire name ad.filled
An ad was returned and linked to the placement.
.noFill(NoFillData) — wire name ad.no-fill
No ad was returned for the placement (server skipped).
.adHeight(AdHeightData) — wire name ad.height
The ad iframe reported a new height. Use to size the surrounding container (especially in UIKit UITableView / UICollectionView cells).