# ByteLyst Platform SDK — Android (Kotlin)
Kotlin SDK for the ByteLyst platform. Provides broadcast messaging, surveys, authentication, telemetry, and more.
## Installation
### Gradle
Add to your `build.gradle.kts`:
```kotlin
dependencies {
implementation("com.bytelyst:platform-sdk:1.0.0")
}
```
### Maven
```xml
com.bytelyst
platform-sdk
1.0.0
```
## Quick Start
```kotlin
import com.bytelyst.platform.*
// Configure the SDK
val config = BLPlatformConfig(
productId = "lysnrai",
baseURL = "https://api.bytelyst.io/v1",
getAuthToken = { authRepository.getToken() }
)
// Create clients
val broadcastClient = BLBroadcastClient(config)
val surveyClient = BLSurveyClient(config)
```
## Broadcast Client
### Basic Usage
```kotlin
import com.bytelyst.platform.*
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
class BroadcastManager(
private val client: BLBroadcastClient
) {
private val _messages = MutableStateFlow>(emptyList())
val messages: StateFlow> = _messages
private val _unreadCount = MutableStateFlow(0)
val unreadCount: StateFlow = _unreadCount
fun startListening() {
client.startPolling(60000L) { messages ->
_messages.value = messages
_unreadCount.value = messages.count { it.status == MessageStatus.UNREAD }
}
}
fun stopListening() {
client.stopPolling()
}
suspend fun markRead(messageId: String) {
client.markRead(messageId)
}
suspend fun dismiss(messageId: String) {
client.markDismissed(messageId)
}
suspend fun handleTap(message: InAppMessage) {
client.trackClick(message.id)
message.ctaUrl?.let { url ->
// Open URL with your navigation system
navigationService.openUrl(url)
}
markRead(message.id)
}
}
```
### Jetpack Compose Integration
```kotlin
import com.bytelyst.platform.ui.*
@Composable
fun AppContent() {
val broadcastManager = remember { BroadcastManager(broadcastClient) }
val messages by broadcastManager.messages.collectAsState()
val unreadCount by broadcastManager.unreadCount.collectAsState()
LaunchedEffect(Unit) {
broadcastManager.startListening()
}
Scaffold(
topBar = {
// Banner for unread messages
InAppMessageBanner(
client = broadcastClient,
position = BannerPosition.TOP
)
}
) { padding ->
MainContent(modifier = Modifier.padding(padding))
}
}
```
### Modal Messages
```kotlin
@Composable
fun AppRoot() {
val broadcastClient = remember { BLBroadcastClient(config) }
Box(modifier = Modifier.fillMaxSize()) {
NavigationHost()
// Modal overlay
BroadcastModal(client = broadcastClient)
}
}
```
## Survey Client
### Basic Usage
```kotlin
import com.bytelyst.platform.*
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
class SurveyManager(
private val client: BLSurveyClient
) {
private val _activeSurvey = MutableStateFlow(null)
val activeSurvey: StateFlow = _activeSurvey
private val _currentQuestionIndex = MutableStateFlow(0)
val currentQuestionIndex: StateFlow = _currentQuestionIndex
private val _answers = MutableStateFlow