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.
Installation
Section titled “Installation”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.
WhiskrKit
Section titled “WhiskrKit”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, ) }}| Parameter | Type | Description |
|---|---|---|
context | Context | Application context; only the application context is retained |
apiKey | String | Your WhiskrKit API key from the dashboard |
withMockedSurveys | Boolean | Use 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.
present(surveyId)
Section titled “present(surveyId)”Imperatively presents a survey, bypassing eligibility checks.
WhiskrKit.present(surveyId = "nps-survey")| Parameter | Type | Description |
|---|---|---|
surveyId | String | The 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.
checkAndPresent(surveyId)
Section titled “checkAndPresent(surveyId)”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")| Parameter | Type | Description |
|---|---|---|
surveyId | String | The identifier of the survey to evaluate and potentially present |
Requires a WhiskrKitHost in the composition. If eligibility fails, this is a no-op.
Composables
Section titled “Composables”WhiskrKitHost(modifier, theme, content)
Section titled “WhiskrKitHost(modifier, theme, content)”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.WhiskrKitHostimport eu.whiskrkit.theme.WhiskrKitTheme
setContent { MyAppTheme { WhiskrKitHost(theme = WhiskrKitTheme(/* ... */)) { AppContent() } }}| Parameter | Type | Description |
|---|---|---|
modifier | Modifier | Standard Compose modifier. Defaults to Modifier |
theme | WhiskrKitTheme? | Optional theme applied to all survey UI. Defaults to null |
content | @Composable () -> Unit | Your app content |
Without a host in the composition, present / checkAndPresent render nothing (buffered at most).
WhiskrKitSurvey(identifier)
Section titled “WhiskrKitSurvey(identifier)”Automatically evaluates eligibility and presents a survey when the composable enters the composition.
import eu.whiskrkit.ui.WhiskrKitSurvey
@Composablefun HomeScreen() { WhiskrKitSurvey(identifier = "nps-survey")}| Parameter | Type | Description |
|---|---|---|
identifier | String | The survey identifier from the dashboard |
Theming
Section titled “Theming”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.
Platform differences from iOS
Section titled “Platform differences from iOS”- 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/ToastPlacementare iOS-only. Android has no placement concept. - Theme is set via the host, not a
setThememethod. - Buffered triggers. A
presentfired before the host exists is buffered on Android; on iOS it is a no-op.
Platform requirements
Section titled “Platform requirements”| Requirement | Minimum |
|---|---|
minSdk | 26 |
| UI toolkit | Jetpack Compose |