Skip to content

Android (Kotlin)

The Android SDK renders surveys with Jetpack Compose. It mirrors the iOS SDK’s model (initialise once, attach a host, present surveys by identifier), with a few platform-specific names noted below.

The SDK is published to Maven Central. Add it to your module’s build.gradle.kts:

dependencies {
implementation("eu.whiskrkit:whiskrkit-android:0.1.3")
}

Make sure mavenCentral() is in your repositories and your app’s minSdk is 26 or higher.

The object WhiskrKit is the entry point for all SDK interactions. All methods are synchronous, return Unit, and should be called on the main thread.


initialize(context, apiKey, withMockedSurveys)

Section titled “initialize(context, apiKey, withMockedSurveys)”

Initialises the SDK. Call once from Application.onCreate() on the main thread, before any other WhiskrKit method. Only the application context is retained.

import eu.whiskrkit.WhiskrKit
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
WhiskrKit.initialize(
context = this,
apiKey = "wk_live_your_api_key",
withMockedSurveys = false,
)
}
}
ParameterTypeDescription
contextContextApplication context; only the application context is retained
apiKeyStringYour WhiskrKit API key from the dashboard
withMockedSurveysBooleanUse local mock data instead of hitting the API. Defaults to false

When withMockedSurveys is true, the SDK bypasses all network calls, which is useful during development and UI testing.


Imperatively presents a survey, bypassing eligibility checks.

WhiskrKit.present(surveyId = "nps-survey")
ParameterTypeDescription
surveyIdStringThe identifier of the survey to present

Requires a WhiskrKitHost in the composition. Unlike iOS, a present call made before a host exists is buffered and delivered to the first host that appears.


Checks eligibility and presents a survey if the user qualifies. The timing is yours; the targeting decision stays with the backend.

WhiskrKit.checkAndPresent(surveyId = "settings-feedback")
ParameterTypeDescription
surveyIdStringThe identifier of the survey to evaluate and potentially present

Requires a WhiskrKitHost in the composition. If eligibility fails, this is a no-op.

Registers the attachment point for surveys and hosts all presentation (sheet, full-screen, banner). Wrap your app’s root content in it, once.

import eu.whiskrkit.ui.WhiskrKitHost
import eu.whiskrkit.theme.WhiskrKitTheme
setContent {
MyAppTheme {
WhiskrKitHost(theme = WhiskrKitTheme(/* ... */)) {
AppContent()
}
}
}
ParameterTypeDescription
modifierModifierStandard Compose modifier. Defaults to Modifier
themeWhiskrKitTheme?Optional theme applied to all survey UI. Defaults to null
content@Composable () -> UnitYour app content

Without a host in the composition, present / checkAndPresent render nothing (buffered at most).


Automatically evaluates eligibility and presents a survey when the composable enters the composition.

import eu.whiskrkit.ui.WhiskrKitSurvey
@Composable
fun HomeScreen() {
WhiskrKitSurvey(identifier = "nps-survey")
}
ParameterTypeDescription
identifierStringThe survey identifier from the dashboard

Unlike iOS (which has setTheme), Android takes the theme as a parameter on WhiskrKitHost:

WhiskrKitHost(theme = WhiskrKitTheme(/* ... */)) { AppContent() }

WhiskrKitTheme is composed of Compose types (Color, TextStyle, Dp) with nested container, button, text, and selection themes. WhiskrKit supports dark mode and Dynamic Type natively; supply adaptive colours for best results.

  • Toast is called banner. Android’s toast-style surveys use the name “banner” throughout the theme API (ContainerTheme.banner); iOS calls the same style “toast”.
  • No placement API. SheetPlacement / ToastPlacement are iOS-only. Android has no placement concept.
  • Theme is set via the host, not a setTheme method.
  • Buffered triggers. A present fired before the host exists is buffered on Android; on iOS it is a no-op.
RequirementMinimum
minSdk26
UI toolkitJetpack Compose