Documentation Index
Fetch the complete documentation index at: https://docs.kontext.so/llms.txt
Use this file to discover all available pages before exploring further.
Handling no-fill
Subscribe to.noFill to know when no ad was returned (geo-restriction, frequency cap, etc.). The skipCode payload tells you why.
Sizing ads in UIKit lists
InsideUITableView / UICollectionView cells, observe InlineAdUIView.onHeightChange and trigger a row resize when it fires. The height changes as the ad streams in and stabilizes at the final value.
Live-updating session options
A subset of session options can be live-updated without recreating the session. Updates are read on the next/preload, so changes take effect on the next user message.
variantId, regulatory, userEmail, advertisingId, vendorId. Non-nil fields overwrite; nil fields are left unchanged. To clear a field, recreate the session.
Live-updating consent mid-session
When the user updates their consent in your CMP, call:Switching character
The activecharacter cannot be live-updated — the accumulated message history belongs to the original persona, so swapping mid-session would leave messages targeted at the wrong character.
To switch character, destroy the current session and create a new one:
publisherToken, userId, conversationId, and enabledPlacementCodes — recreate the session whenever any of those change.
Loading older messages (conversation restore)
When restoring a conversation from your backend, calladdMessage(_:) once per historical message in order. Preloads are debounced by 10 ms, so rapid sequential calls coalesce into a single preload for the most recent user message — you won’t fire one preload per restored message.
Pass every message, suppress ads with trackOnly
Always feed every message into the session, even when you don’t want an ad to appear (e.g. when a user is on a free trial, in a no-ads region, or you’ve decided to show ads only every Nth message). Skipping addMessage(_:) calls breaks the conversation context the server relies on for targeting. See Pacing for the full pattern.
trackOnly: true, the preload still fires (server keeps full analytics) but no .filled event will arrive for that message and session.createAd(...) won’t resolve to an ad.
SwiftUI
The SDK ships UIKit views only. WrapInlineAdUIView in a UIViewRepresentable to embed it in SwiftUI: