Android SDK
Drop-in support SDK for Android apps. Jetpack Compose, Activity launches, or headless API.
Android SDK
Drop-in support SDK for Android apps. Replace Zendesk with a few lines of code.
Requirements
- Min SDK 24 (Android 7.0+)
- Kotlin 2.0+
- Jetpack Compose (BOM 2024.12.01+)
- OkHttp 4.12
- kotlinx-serialization
Installation
Add the Premex artifact repository and the dependency to your module-level build.gradle.kts:
Initialization
Call PremexSupport.initialize() once, as early as possible — typically in Application.onCreate() or your main Activity:
// Application.kt
PremexSupport.initialize(
context = applicationContext,
config = PremexSupportConfig(
baseUrl = "https://support.premex.se",
productSlug = "your-product-slug",
),
)
Jetpack Compose Integration (Recommended)
Embed the SDK's composables directly in your Compose navigation graph for the most seamless experience.
// Chat screen
PremexChatScreen(
modifier = Modifier.fillMaxSize(),
onNavigateBack = { navController.popBackStack() },
)
// Form screen
PremexFormScreen(
formType = FormType.BUG_REPORT,
modifier = Modifier.fillMaxSize(),
onNavigateBack = { navController.popBackStack() },
onSubmitted = { navController.popBackStack() },
)
A full NavHost example with chat and form routes:
NavHost(navController, startDestination = "home") {
composable("home") {
HomeScreen(
onOpenChat = { navController.navigate("chat") },
onOpenBugReport = { navController.navigate("form/bug_report") },
onOpenFeatureRequest = { navController.navigate("form/feature_request") },
onOpenSupport = { navController.navigate("form/support") },
)
}
composable("chat") {
PremexChatScreen(
modifier = Modifier.fillMaxSize(),
onNavigateBack = { navController.popBackStack() },
)
}
composable("form/{formType}") { backStackEntry ->
val formType = FormType.valueOf(
backStackEntry.arguments?.getString("formType")
?.uppercase() ?: "SUPPORT",
)
PremexFormScreen(
formType = formType,
modifier = Modifier.fillMaxSize(),
onNavigateBack = { navController.popBackStack() },
onSubmitted = { navController.popBackStack() },
)
}
}
Wrap in PremexSupportTheme for the SDK's default Material 3 styling, or use your own MaterialTheme to customise colours, typography, and shapes.
Activity Integration (Quick Start)
For apps that don't use Compose navigation, launch the SDK's built-in activities directly:
// Launch chat
PremexSupport.showChat(context)
// Launch form
PremexSupport.showForm(context, FormType.SUPPORT)
PremexSupport.showForm(context, FormType.FEATURE_REQUEST)
PremexSupport.showForm(context, FormType.BUG_REPORT)
Form Types
Each form type presents a different set of fields to the user:
| Form Type | Fields |
|---|---|
FormType.SUPPORT | Subject, Message |
FormType.FEATURE_REQUEST | Title, Use Case, Proposed Solution, Priority |
FormType.BUG_REPORT | Title, Steps to Reproduce, Expected Behavior, Actual Behavior, Environment |
Headless API
Build a fully custom UI on top of the SDK's networking and identity layers:
val client = PremexSupport.apiClient
val customerId = PremexSupport.identityManager.customerId
// List conversations
val result = client.listConversations(customerId)
// Create conversation
val created = client.createConversation(
customerId = customerId,
subject = "Need help",
message = "I can't find the settings page",
)
// Real-time events
PremexSupport.sseEventSource
.observeEvents(conversationId, customerId)
.collect { event ->
when (event) {
is ConversationEvent.NewComment -> { /* new message */ }
is ConversationEvent.StateUpdate -> { /* status changed */ }
else -> { /* other events */ }
}
}
The observeEvents function returns a Flow<ConversationEvent> backed by an SSE connection. It reconnects automatically on network failures.
Theming
PremexSupportTheme provides Material 3 defaults with full light/dark mode support. To match your app's brand, wrap the SDK composables in your own MaterialTheme:
MaterialTheme(
colorScheme = YourColorScheme,
) {
PremexChatScreen(...)
}
The SDK reads colours, typography, and shapes from the nearest MaterialTheme in the composition tree, so no additional configuration is required.
Customer Identity
- A unique
cust_<UUID>identifier is auto-generated on first use. - Stored in encrypted SharedPreferences (AndroidX Security).
- Persists across app sessions and app updates.
- Clear it manually when needed:
PremexSupport.identityManager.clear()
Migration from Zendesk
Switching from the Zendesk SDK is straightforward. The API surface maps almost one-to-one:
| Zendesk | Premex Support |
|---|---|
Zendesk.initialize(...) | PremexSupport.initialize(...) |
MessagingActivity.show(...) | PremexSupport.showChat(context) |
RequestActivity.show(...) | PremexSupport.showForm(context) |
Architecture
The SDK is organised in layers, each of which can be used independently:
PremexSupport— Singleton entry point. Owns the lifecycle of all other components.PremexApiClient— REST API client built on OkHttp + Kotlin Coroutines.SseEventSource— Real-time event stream that converts SSE into aFlow<ConversationEvent>.CustomerIdentityManager— Encrypted identity storage backed by AndroidX Security.- Compose UI —
PremexChatScreen,PremexFormScreen, and supporting composables.