---
title: core and data
slug: sdk/android-sdk-api-reference-core-and-data
createdAt: 2026-11-04T11:40:05.969Z
---

# no.kindly.chatsdk.chat.core

## AppStateObserver

`class`

```kotlin
class AppStateObserver : DefaultLifecycleObserver
```

Observes application process lifecycle (foreground/background) and manages reconnection behavior and cleanup using ProcessLifecycleOwner for reliable app-level state detection.

| Member             | Declaration                                        | Description                                                                                                                                                           |
| ------------------ | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AppStateObserver` | `constructor()`                                    |                                                                                                                                                                       |
| `initialize`       | `suspend fun initialize(application: Application)` | Initialize the observer by registering it with ProcessLifecycleOwner Must be called from main thread as ProcessLifecycleOwner requires it                             |
| `onStart`          | `open override fun onStart(owner: LifecycleOwner)` | Called when app process moves to foreground (ProcessLifecycleOwner.onStart) Handles reconnection and re-enabling of auto-reconnect after cleanup                      |
| `onStop`           | `open override fun onStop(owner: LifecycleOwner)`  | Called when app process moves to background (ProcessLifecycleOwner.onStop) Triggers cleanup to prevent non-daemon threads from blocking JVM shutdown (ANR prevention) |

## ChatSdkFileProvider

`class`

```kotlin
class ChatSdkFileProvider : FileProvider
```

The SDK's FileProvider. Its `onCreate` also runs at process start, before any host code, which makes it the earliest place to capture the application context: a Kindly push that FCM delivers before the host calls `start()` (process death, reboot) needs one to decrypt and post the banner.

| Member                | Declaration                             | Description |
| --------------------- | --------------------------------------- | ----------- |
| `ChatSdkFileProvider` | `constructor()`                         |             |
| `onCreate`            | `open override fun onCreate(): Boolean` |             |

## Constants

`object`

```kotlin
object Constants
```

| Member                    | Declaration                                 | Description |
| ------------------------- | ------------------------------------------- | ----------- |
| `notificationSourceKey`   | `const val notificationSourceKey: String`   |             |
| `notificationSourceValue` | `const val notificationSourceValue: String` |             |
| `sdkName`                 | `const val sdkName: String`                 |             |
| `subsystem`               | `const val subsystem: String`               |             |

## ContextHolder

`object`

```kotlin
object ContextHolder
```

The application context. Written by `ChatSdkFileProvider` at process start and by `SDKDependencies.setup`; read by the push path that may run before `start()`.

| Member       | Declaration                          | Description |
| ------------ | ------------------------------------ | ----------- |
| `appContext` | `@Volatile var appContext: Context?` |             |

## DateParseException

`class`

```kotlin
class DateParseException(message: String, cause: Throwable? = null) : Exception
```

Custom exception for date parsing errors.

| Member               | Declaration                                              | Description |
| -------------------- | -------------------------------------------------------- | ----------- |
| `DateParseException` | `constructor(message: String, cause: Throwable? = null)` |             |

## DateUtils

`object`

```kotlin
object DateUtils
```

Utility class for handling date conversions.

| Member       | Declaration                                | Description                                                                                                                                                                                                                                    |
| ------------ | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `now`        | `val now: String`                          | Current time formatted with the primary UTC pattern. Evaluated on each access (the previous eager `val` captured class-load time, not the real "now").                                                                                         |
| `decodeDate` | `fun decodeDate(dateString: String): Date` | Decodes a date string into a `Date` object. **Parameters** - `dateString`: The date string to decode. **Returns** - The corresponding `Date` object. **Throws** - `DateParseException`: If the date string does not match any expected format. |

## DI

`object`

```kotlin
object DI
```

Entry point for SDK dependency initialization. Delegates to `SDKDependencies` which manages all instances.

## LogLevelEnum

`enum`

```kotlin
enum LogLevelEnum : Enum<LogLevelEnum>
```

| Member    | Declaration                                | Description                                                                                                                                                                                                                                                                                                                |
| --------- | ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `VERBOSE` | `VERBOSE`                                  |                                                                                                                                                                                                                                                                                                                            |
| `DEBUG`   | `DEBUG`                                    |                                                                                                                                                                                                                                                                                                                            |
| `INFO`    | `INFO`                                     |                                                                                                                                                                                                                                                                                                                            |
| `WARNING` | `WARNING`                                  |                                                                                                                                                                                                                                                                                                                            |
| `ERROR`   | `ERROR`                                    |                                                                                                                                                                                                                                                                                                                            |
| `entries` | `val entries: EnumEntries<LogLevelEnum>`   | Returns a representation of an immutable list of all enum entries, in the order they're declared. This method may be used to iterate over the enum entries.                                                                                                                                                                |
| `valueOf` | `fun valueOf(value: String): LogLevelEnum` | Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.) **Throws** - `kotlin.IllegalArgumentException`: if this enum type has no constant with the specified name |
| `values`  | `fun values(): Array<LogLevelEnum>`        | Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants.                                                                                                                                                                         |

# no.kindly.chatsdk.chat.core.config

## Config

`object`

```kotlin
object Config
```

| Member                    | Declaration                                                                                  | Description |
| ------------------------- | -------------------------------------------------------------------------------------------- | ----------- |
| `customBuildtimeDefaults` | `val customBuildtimeDefaults: Config.CustomConfig`                                           |             |
| `developmentDefaults`     | `val developmentDefaults: Config.CustomConfig`                                               |             |
| `productionDefaults`      | `val productionDefaults: Config.CustomConfig`                                                |             |
| `stagingDefaults`         | `val stagingDefaults: Config.CustomConfig`                                                   |             |
| `baseUrl`                 | `fun baseUrl(env: Config.Environment, override: Config.CustomConfig? = null): String`        |             |
| `defaultsFor`             | `fun defaultsFor(env: Config.Environment): Config.CustomConfig`                              |             |
| `otlpBearerToken`         | `fun otlpBearerToken(env: Config.Environment, hasRuntimeOverride: Boolean = false): String`  |             |
| `otlpUrl`                 | `fun otlpUrl(env: Config.Environment, override: Config.CustomConfig? = null): String`        |             |
| `pusherKey`               | `fun pusherKey(env: Config.Environment, override: Config.CustomConfig? = null): String`      |             |
| `settingsUrl`             | `fun settingsUrl(env: Config.Environment, override: Config.CustomConfig? = null): String`    |             |
| `webviewBaseUrl`          | `fun webviewBaseUrl(env: Config.Environment, override: Config.CustomConfig? = null): String` |             |

## Config.CustomConfig

`data class`

```kotlin
data class CustomConfig(val baseUrl: String, val settingsUrl: String, val webviewBaseUrl: String, val otlpUrl: String, val pusherKey: String)
```

| Member           | Declaration                                                                                                     | Description |
| ---------------- | --------------------------------------------------------------------------------------------------------------- | ----------- |
| `CustomConfig`   | `constructor(baseUrl: String, settingsUrl: String, webviewBaseUrl: String, otlpUrl: String, pusherKey: String)` |             |
| `baseUrl`        | `val baseUrl: String`                                                                                           |             |
| `otlpUrl`        | `val otlpUrl: String`                                                                                           |             |
| `pusherKey`      | `val pusherKey: String`                                                                                         |             |
| `settingsUrl`    | `val settingsUrl: String`                                                                                       |             |
| `webviewBaseUrl` | `val webviewBaseUrl: String`                                                                                    |             |

## Config.Environment

`enum`

```kotlin
enum Environment : Enum<Config.Environment>
```

| Member    | Declaration                                      | Description                                                                                                                                                                                                                                                                                                                |
| --------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PROD`    | `PROD`                                           |                                                                                                                                                                                                                                                                                                                            |
| `DEV`     | `DEV`                                            |                                                                                                                                                                                                                                                                                                                            |
| `STAGING` | `STAGING`                                        |                                                                                                                                                                                                                                                                                                                            |
| `CUSTOM`  | `CUSTOM`                                         |                                                                                                                                                                                                                                                                                                                            |
| `entries` | `val entries: EnumEntries<Config.Environment>`   | Returns a representation of an immutable list of all enum entries, in the order they're declared. This method may be used to iterate over the enum entries.                                                                                                                                                                |
| `raw`     | `val raw: String`                                |                                                                                                                                                                                                                                                                                                                            |
| `valueOf` | `fun valueOf(value: String): Config.Environment` | Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.) **Throws** - `kotlin.IllegalArgumentException`: if this enum type has no constant with the specified name |
| `values`  | `fun values(): Array<Config.Environment>`        | Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants.                                                                                                                                                                         |

## Config.Environment.Companion

`object`

```kotlin
object Companion
```

| Member | Declaration                                  | Description                                                                                         |
| ------ | -------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `from` | `fun from(raw: String?): Config.Environment` | Parse a raw env string from BuildConfig or RuntimeEnvironment; falls back to PROD on unknown input. |

## RuntimeEnvironment

`object`

```kotlin
object RuntimeEnvironment
```

| Member           | Declaration                                                                  | Description                                                                                                                                                                                                                                                                                                                                                                               |
| ---------------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `lastError`      | `@Volatile var lastError: String?`                                           | The reason the last `save` or `clear` failed, or null if the last one succeeded. Exposed because the Settings screen showed a bare "Failed to write EncryptedSharedPreferences" with no cause, and the cause was only logged through `Logger`, which is gated on `verboseLogging`. So the one message that explains the failure was invisible in exactly the situation where you need it. |
| `clear`          | `fun clear(context: Context): Boolean`                                       |                                                                                                                                                                                                                                                                                                                                                                                           |
| `current`        | `fun current(): Config.Environment`                                          | Resolved env for this process. Falls back to BuildConfig if not initialized.                                                                                                                                                                                                                                                                                                              |
| `customOverride` | `fun customOverride(): Config.CustomConfig?`                                 | User-supplied custom URL/Pusher set, iff current() == CUSTOM and an override is stored.                                                                                                                                                                                                                                                                                                   |
| `initialize`     | `fun initialize(context: Context)`                                           | Cache the resolved env (override → BuildConfig.ENVIRONMENT) for this process. Must be called early in SDK init, before any callsite that routes URLs/Pusher key through `Config`. ChatKindlySDK's `init {}` calls this right after `DI.setup(application)`.                                                                                                                               |
| `load`           | `fun load(context: Context): RuntimeEnvironment.Override?`                   | Read the persisted override (uncached). Used by the Settings screen to display current state.                                                                                                                                                                                                                                                                                             |
| `save`           | `fun save(context: Context, override: RuntimeEnvironment.Override): Boolean` |                                                                                                                                                                                                                                                                                                                                                                                           |

## RuntimeEnvironment.Override

`data class`

```kotlin
data class Override(val environment: String, val customConfig: Config.CustomConfig?)
```

| Member         | Declaration                                                            | Description |
| -------------- | ---------------------------------------------------------------------- | ----------- |
| `Override`     | `constructor(environment: String, customConfig: Config.CustomConfig?)` |             |
| `customConfig` | `val customConfig: Config.CustomConfig?`                               |             |
| `environment`  | `val environment: String`                                              |             |

# no.kindly.chatsdk.chat.core.metrics

## MetricKeys

`enum`

```kotlin
enum MetricKeys : Enum<MetricKeys>
```

All available OpenTelemetry metrics for the Kindly SDK These correspond to metrics allowed in the OTLP collector filter/strict configuration

| Member                         | Declaration                              | Description                                                                                                                                                                                                                                                                                                                |
| ------------------------------ | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `TEST_METRIC`                  | `TEST_METRIC`                            |                                                                                                                                                                                                                                                                                                                            |
| `UI_BUTTON_CLICKED`            | `UI_BUTTON_CLICKED`                      |                                                                                                                                                                                                                                                                                                                            |
| `UI_SCREEN_TAPPED`             | `UI_SCREEN_TAPPED`                       |                                                                                                                                                                                                                                                                                                                            |
| `NAVIGATION_SCREEN_VIEWED`     | `NAVIGATION_SCREEN_VIEWED`               |                                                                                                                                                                                                                                                                                                                            |
| `NAVIGATION_SCREEN_TRANSITION` | `NAVIGATION_SCREEN_TRANSITION`           |                                                                                                                                                                                                                                                                                                                            |
| `SOCKET_STATUS_CHANGED`        | `SOCKET_STATUS_CHANGED`                  |                                                                                                                                                                                                                                                                                                                            |
| `SOCKET_MESSAGE`               | `SOCKET_MESSAGE`                         |                                                                                                                                                                                                                                                                                                                            |
| `SOCKET_RECONNECT`             | `SOCKET_RECONNECT`                       |                                                                                                                                                                                                                                                                                                                            |
| `API_REQUEST`                  | `API_REQUEST`                            |                                                                                                                                                                                                                                                                                                                            |
| `API_RESPONSE`                 | `API_RESPONSE`                           |                                                                                                                                                                                                                                                                                                                            |
| `API_REQUEST_DURATION`         | `API_REQUEST_DURATION`                   |                                                                                                                                                                                                                                                                                                                            |
| `CHAT_MESSAGE`                 | `CHAT_MESSAGE`                           |                                                                                                                                                                                                                                                                                                                            |
| `CHAT_MESSAGE_COPIED`          | `CHAT_MESSAGE_COPIED`                    |                                                                                                                                                                                                                                                                                                                            |
| `CHAT_FORM`                    | `CHAT_FORM`                              |                                                                                                                                                                                                                                                                                                                            |
| `CHAT_QUICK_REPLY_CLICKED`     | `CHAT_QUICK_REPLY_CLICKED`               |                                                                                                                                                                                                                                                                                                                            |
| `CHAT_SCROLLED`                | `CHAT_SCROLLED`                          |                                                                                                                                                                                                                                                                                                                            |
| `CHAT_RATED`                   | `CHAT_RATED`                             |                                                                                                                                                                                                                                                                                                                            |
| `SESSION_LIFECYCLE`            | `SESSION_LIFECYCLE`                      |                                                                                                                                                                                                                                                                                                                            |
| `SESSION_DURATION`             | `SESSION_DURATION`                       |                                                                                                                                                                                                                                                                                                                            |
| `DEVICE_INFO`                  | `DEVICE_INFO`                            |                                                                                                                                                                                                                                                                                                                            |
| `APP_VERSION`                  | `APP_VERSION`                            |                                                                                                                                                                                                                                                                                                                            |
| `DEVICE_METADATA`              | `DEVICE_METADATA`                        |                                                                                                                                                                                                                                                                                                                            |
| `CONNECTION_EVENT`             | `CONNECTION_EVENT`                       |                                                                                                                                                                                                                                                                                                                            |
| `USER_TYPING`                  | `USER_TYPING`                            |                                                                                                                                                                                                                                                                                                                            |
| `LINK_CLICKED`                 | `LINK_CLICKED`                           |                                                                                                                                                                                                                                                                                                                            |
| `ATTACHMENT_UPLOAD`            | `ATTACHMENT_UPLOAD`                      |                                                                                                                                                                                                                                                                                                                            |
| `ATTACHMENT_DOWNLOAD`          | `ATTACHMENT_DOWNLOAD`                    |                                                                                                                                                                                                                                                                                                                            |
| `MEDIA_PLAYED`                 | `MEDIA_PLAYED`                           |                                                                                                                                                                                                                                                                                                                            |
| `CAMERA_OPENED`                | `CAMERA_OPENED`                          |                                                                                                                                                                                                                                                                                                                            |
| `NOTIFICATION_LIFECYCLE`       | `NOTIFICATION_LIFECYCLE`                 |                                                                                                                                                                                                                                                                                                                            |
| `APP_LIFECYCLE`                | `APP_LIFECYCLE`                          |                                                                                                                                                                                                                                                                                                                            |
| `NETWORK_CONNECTIVITY_CHANGED` | `NETWORK_CONNECTIVITY_CHANGED`           |                                                                                                                                                                                                                                                                                                                            |
| `NETWORK_QUALITY_MEASURED`     | `NETWORK_QUALITY_MEASURED`               |                                                                                                                                                                                                                                                                                                                            |
| `AGENT_EVENT`                  | `AGENT_EVENT`                            |                                                                                                                                                                                                                                                                                                                            |
| `FEEDBACK_EVENT`               | `FEEDBACK_EVENT`                         |                                                                                                                                                                                                                                                                                                                            |
| `CONFIG_EVENT`                 | `CONFIG_EVENT`                           |                                                                                                                                                                                                                                                                                                                            |
| `LANGUAGE_CHANGED`             | `LANGUAGE_CHANGED`                       |                                                                                                                                                                                                                                                                                                                            |
| `THEME_CHANGED`                | `THEME_CHANGED`                          |                                                                                                                                                                                                                                                                                                                            |
| `AUTH_EVENT`                   | `AUTH_EVENT`                             |                                                                                                                                                                                                                                                                                                                            |
| `ERROR_OCCURRED`               | `ERROR_OCCURRED`                         |                                                                                                                                                                                                                                                                                                                            |
| `CRASH_DETECTED`               | `CRASH_DETECTED`                         |                                                                                                                                                                                                                                                                                                                            |
| `PERFORMANCE_MEMORY_USAGE`     | `PERFORMANCE_MEMORY_USAGE`               |                                                                                                                                                                                                                                                                                                                            |
| `PERFORMANCE_NETWORK_BYTES`    | `PERFORMANCE_NETWORK_BYTES`              |                                                                                                                                                                                                                                                                                                                            |
| `PERFORMANCE_RENDER_LAG`       | `PERFORMANCE_RENDER_LAG`                 |                                                                                                                                                                                                                                                                                                                            |
| `CACHE_EVENT`                  | `CACHE_EVENT`                            |                                                                                                                                                                                                                                                                                                                            |
| `DATABASE_OPERATION`           | `DATABASE_OPERATION`                     |                                                                                                                                                                                                                                                                                                                            |
| `ACCESSIBILITY_EVENT`          | `ACCESSIBILITY_EVENT`                    |                                                                                                                                                                                                                                                                                                                            |
| `PROACTIVE_EVENT`              | `PROACTIVE_EVENT`                        |                                                                                                                                                                                                                                                                                                                            |
| `EVENT_CUSTOM`                 | `EVENT_CUSTOM`                           |                                                                                                                                                                                                                                                                                                                            |
| `entries`                      | `val entries: EnumEntries<MetricKeys>`   | Returns a representation of an immutable list of all enum entries, in the order they're declared. This method may be used to iterate over the enum entries.                                                                                                                                                                |
| `value`                        | `val value: String`                      |                                                                                                                                                                                                                                                                                                                            |
| `valueOf`                      | `fun valueOf(value: String): MetricKeys` | Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.) **Throws** - `kotlin.IllegalArgumentException`: if this enum type has no constant with the specified name |
| `values`                       | `fun values(): Array<MetricKeys>`        | Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants.                                                                                                                                                                         |

## MetricsService

`object`

```kotlin
object MetricsService
```

Service for sending OpenTelemetry metrics to OTLP endpoint Completely failsafe - all operations are non-blocking and errors are silently handled Singleton object like SentryHelper for direct access

| Member                    | Declaration                                                                                                                          | Description                                                                                                                                                                                                                                                      |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialize`              | `fun initialize(context: Context)`                                                                                                   | Initialize the metrics service. Should be called once during SDK initialization.                                                                                                                                                                                 |
| `sendDeviceInfo`          | `fun sendDeviceInfo()`                                                                                                               | Send device information metrics on SDK initialization                                                                                                                                                                                                            |
| `sendEvent`               | `fun sendEvent(metric: MetricKeys, value: Long = 1, labels: Map<String, String> = emptyMap(), allowInBackground: Boolean = false)`   | Send a metric event with optional labels COMPLETELY FAILSAFE - will never crash or block                                                                                                                                                                         |
| `sendGaugeMetric`         | `fun sendGaugeMetric(metric: MetricKeys, value: Long, labels: Map<String, String> = emptyMap(), allowInBackground: Boolean = false)` | Send a gauge metric (for values that can go up or down) Used for things like duration, memory usage, active connections                                                                                                                                          |
| `setBotKey`               | `fun setBotKey(key: String)`                                                                                                         | Update bot\_key when SDK initializes                                                                                                                                                                                                                             |
| `setBotName`              | `fun setBotName(name: String)`                                                                                                       | Update bot\_name when settings load                                                                                                                                                                                                                              |
| `setChatId`               | `fun setChatId(chatId: String)`                                                                                                      | Update chat\_id when chat session starts                                                                                                                                                                                                                         |
| `setEnabled`              | `fun setEnabled(enabled: Boolean)`                                                                                                   | Enable or disable metrics sending (INTERNAL USE ONLY) Set synchronously to avoid race condition where sendEvent() checks isEnabled before the async coroutine has set it. This ensures metrics sent immediately after setEnabled(true) are not silently dropped. |
| `setTrackAppLifecycle`    | `fun setTrackAppLifecycle(enabled: Boolean)`                                                                                         | Enable or disable app lifecycle event tracking (foreground/background) Call this when SDK starts (true) or disconnects (false)                                                                                                                                   |
| `shouldTrackAppLifecycle` | `fun shouldTrackAppLifecycle(): Boolean`                                                                                             | Check if app lifecycle tracking is enabled                                                                                                                                                                                                                       |
| `trackAPIRequest`         | `fun trackAPIRequest(endpoint: String, method: String, statusCode: Int)`                                                             |                                                                                                                                                                                                                                                                  |
| `trackButtonClick`        | `fun trackButtonClick(buttonId: String, screen: String)`                                                                             |                                                                                                                                                                                                                                                                  |
| `trackChatMessage`        | `fun trackChatMessage(direction: String, messageType: String, sender: String? = null)`                                               |                                                                                                                                                                                                                                                                  |
| `trackCurrentScreenTap`   | `fun trackCurrentScreenTap(x: Float, y: Float, screenWidth: Int, screenHeight: Int)`                                                 |                                                                                                                                                                                                                                                                  |
| `trackCustomEvent`        | `fun trackCustomEvent(eventType: String, category: String? = null, action: String? = null, detail: String? = null)`                  |                                                                                                                                                                                                                                                                  |
| `trackError`              | `fun trackError(errorType: String, errorCode: String? = null, screen: String? = null)`                                               |                                                                                                                                                                                                                                                                  |
| `trackScreenTap`          | `fun trackScreenTap(screenName: String, x: Float, y: Float, screenWidth: Int, screenHeight: Int)`                                    |                                                                                                                                                                                                                                                                  |
| `trackScreenView`         | `fun trackScreenView(screenName: String, previousScreen: String? = null, duration: Int? = null)`                                     |                                                                                                                                                                                                                                                                  |
| `trackScroll`             | `fun trackScroll(screenName: String, direction: String)`                                                                             |                                                                                                                                                                                                                                                                  |
| `trackSessionEnd`         | `fun trackSessionEnd(reason: String, duration: Int)`                                                                                 |                                                                                                                                                                                                                                                                  |
| `trackSessionStart`       | `fun trackSessionStart()`                                                                                                            |                                                                                                                                                                                                                                                                  |
| `trackSocketStatus`       | `fun trackSocketStatus(status: String, reconnectAttempt: Int = 0)`                                                                   |                                                                                                                                                                                                                                                                  |

# no.kindly.chatsdk.chat.core.socket

## ChannelCallbackAny

`typealias`

```kotlin
typealias ChannelCallbackAny = (PusherEventAny) -> Unit
```

## EventCallback

`typealias`

```kotlin
typealias EventCallback = (Any?) -> Unit
```

## PusherConnectionEstablishedDTO

`data class`

```kotlin
@Serializable
data class PusherConnectionEstablishedDTO(val socketId: String, val activityTimeout: Double)
```

| Member                           | Declaration                                                           | Description |
| -------------------------------- | --------------------------------------------------------------------- | ----------- |
| `PusherConnectionEstablishedDTO` | `constructor(socketId: String, activityTimeout: Double)`              |             |
| `activityTimeout`                | `@SerialName(value = "activity_timeout") val activityTimeout: Double` |             |
| `socketId`                       | `@SerialName(value = "socket_id") val socketId: String`               |             |

## PusherEventAny

`data class`

```kotlin
@Serializable
data class PusherEventAny(val event: String, val data: JsonElement? = null, val channel: String)
```

| Member           | Declaration                                                              | Description |
| ---------------- | ------------------------------------------------------------------------ | ----------- |
| `PusherEventAny` | `constructor(event: String, data: JsonElement? = null, channel: String)` |             |
| `channel`        | `val channel: String`                                                    |             |
| `data`           | `val data: JsonElement?`                                                 |             |
| `event`          | `val event: String`                                                      |             |

# no.kindly.chatsdk.chat.data

## FileStore

`class`

```kotlin
class FileStore(context: Context)
```

`FileStore` file manager responsible for storing and providing info about files.

| Member            | Declaration                                                           | Description                                                                                                                                                                                                                                                        |
| ----------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `FileStore`       | `constructor(context: Context)`                                       |                                                                                                                                                                                                                                                                    |
| `downloadFile`    | `fun downloadFile(fileUrl: String, inputStream: InputStream): String` | Save file in cache **Parameters** - `fileUrl`: - url path - `inputStream`: - representing an input stream of bytes.                                                                                                                                                |
| `getMime`         | `fun getMime(file: File): String?`                                    | Return the MIME type based on the File object. This method tries to determine the MIME type using the ContentResolver for URIs, and if that fails, it falls back to using MimeTypeMap with the file extension. **Parameters** - `file`: - the file object          |
| `getMime`         | `fun getMime(path: String): String?`                                  | Return the MIME type based on the file path. This function first attempts to determine the MIME type based on the URI. If that fails, it falls back to determining the MIME type based on the file extension. **Parameters** - `path`: - the file path as a string |
| `getMime`         | `fun getMime(uri: Uri): String?`                                      | Return the MIME type of the given URI. **Parameters** - `uri`: - URI of the file                                                                                                                                                                                   |
| `getNameFile`     | `fun getNameFile(path: String): String`                               | return name of file **Parameters** - `path`: - file path                                                                                                                                                                                                           |
| `sizeInKb`        | `fun sizeInKb(file: File): Double`                                    | The function return size of the file in KB **Parameters** - `file`: - an abstract representation of `File`                                                                                                                                                         |
| `writeTextToFile` | `fun writeTextToFile(filename: String, data: String): String`         | Write a file in cache **Parameters** - `filename`: - file name - `data`: - contains of the file.                                                                                                                                                                   |

## getRawRequestBodyFromFilePath

`function`

```kotlin
fun getRawRequestBodyFromFilePath(path: String, mimeType: String? = null): RequestBody
```

## isAllowedMimeType

`function`

```kotlin
fun isAllowedMimeType(mimeType: String): Boolean
```

Checks if a MIME type is allowed by the backend. Video types are allowed as a special exception.

## maxAttachmentSizeKb

`function`

```kotlin
fun maxAttachmentSizeKb(mimeType: String): Double
```

## maxAttachmentSizeMb

`function`

```kotlin
fun maxAttachmentSizeMb(mimeType: String): Int
```

## validateAttachment

`function`

```kotlin
fun validateAttachment(mimeType: String, sizeKb: Double): String?
```

English, for logs and exception messages only - `ChatManager.uploadFile` throws it and the user sees a generic failure. Anything shown to the user goes through `attachmentRejection`.
