Reference
Init options
Set these in the Koah(context) { … } initializer block.
| Parameter | Type | Default | Description |
|---|---|---|---|
publisherId | String | — (required) | Your publisher ID from the dashboard. Must be non-blank — a blank id throws on first init. |
logLevel | KoahLogLevel | NONE | NONE, ERROR, WARNING, INFO, or DEBUG — see Debugging. |
baseUrl | String | Production | Leave unset to use production. |
Theme properties
Set these on a KoahTheme passed to ProvideKoahTheme.
| Parameter | Type | Default | Description |
|---|---|---|---|
colorScheme | KoahColorScheme | AUTO | LIGHT, DARK, or AUTO (follows the device via isSystemInDarkTheme()) |
accentColor | Color? | #0D0D0D | Accent for CTA buttons and accents. Text-on-accent is computed automatically for contrast — never expose it. |
fontFamily | FontFamily? | null (inherits from app) | Font family applied to all ad text |
cornerRadius | Dp | 19.dp | Card corner radius |
Slot sizing
KoahCard / KoahAd take optional width and height parameters, each a KoahAxisSize — see Sizing for the model.
| Value | Meaning |
|---|---|
null (default) | Unbounded — wraps content within the parent's own bounds, keeping the most formats in play |
KoahAxisSize.range(min, max) | Wraps content within the dp band. At least one bound is required — range() throws; an unbounded axis is null |
KoahAxisSize.fixed(dp) | Exactly this many dp |
KoahAxisSize.fill() | Fills the parent along this axis. Requires a parent that bounds it — throws at first layout on a scroll axis |
Event handling
The onEvent callback notifies you of ad lifecycle events (served, impression, viewed, click, no-fill). See How Koah works for what each event means and when it fires.
import com.koahlabs.android.KoahEvent
KoahCard(
adContext = KoahAdContext.Conversation(question = q, answer = a),
cacheKey = messageId,
onEvent = { event ->
when (event) {
is KoahEvent.NoAdFill -> { /* no inventory */ }
is KoahEvent.AdServed -> { /* ad delivered */ }
is KoahEvent.ImpressionTracked -> { /* impression tracked */ }
is KoahEvent.AdViewed -> { /* ad visible for sufficient time */ }
is KoahEvent.AdClicked -> { /* user tapped */ }
is KoahEvent.SlotTooSmall -> { /* slot bounds exclude the served ad */ }
is KoahEvent.InAppBrowserClosed -> { /* in-app browser closed, app resumed */ }
else -> {}
}
},
)
Age range buckets
Available KoahAgeRange buckets for visitor attributes:
UNDER_13 remains in the enum for source compatibility, but setAge / setAgeRange ignore any under-13 value with a warning, and a previously stored under-13 value is discarded — see Children's privacy.
Gender values
Available KoahGender values for visitor attributes: MALE, FEMALE, and UNKNOWN (clears the stored value).
Income brackets
Available KoahIncomeBracket values for visitor attributes — annual household income in USD:
| Value | Range |
|---|---|
UNDER_50K | Under $50,000 |
INCOME_50K_TO_100K | $50,000 – $100,000 |
INCOME_100K_TO_150K | $100,000 – $150,000 |
INCOME_150K_TO_200K | $150,000 – $200,000 |
INCOME_200K_PLUS | $200,000 and above |
UNKNOWN | Clears the stored value |