From dfb92b77cc18e01a1a7073f977e02b2d2b91172f Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 23 Nov 2026 17:57:51 +0530 Subject: [PATCH 1/2] docs(android): offline support for the Android UI Kit 6.3.0 Co-Authored-By: Claude Opus 5.5 --- docs.json | 1 + ui-kit/android/calling-integration.mdx | 4 +- ui-kit/android/conversations.mdx | 3 + ui-kit/android/core-features.mdx | 22 +- ui-kit/android/events.mdx | 14 +- ui-kit/android/getting-started-jetpack.mdx | 9 +- ui-kit/android/getting-started-kotlin.mdx | 9 +- ui-kit/android/getting-started.mdx | 9 +- .../android/guide-pin-and-save-messages.mdx | 2 +- ui-kit/android/llms-android-v6.mdx | 7 +- ui-kit/android/localize.mdx | 2 + ui-kit/android/message-composer.mdx | 4 + ui-kit/android/message-list.mdx | 10 + ui-kit/android/message-template.mdx | 2 +- ui-kit/android/methods.mdx | 10 + ui-kit/android/offline-support.mdx | 439 ++++++++++++++++++ ui-kit/android/overview.mdx | 3 +- ui-kit/android/troubleshooting.mdx | 2 +- ui-kit/android/upgrading-from-v5.mdx | 4 +- 19 files changed, 535 insertions(+), 21 deletions(-) create mode 100644 ui-kit/android/offline-support.mdx diff --git a/docs.json b/docs.json index 58788a8cd..d995a7837 100644 --- a/docs.json +++ b/docs.json @@ -1737,6 +1737,7 @@ "group": "Chat", "pages": [ "ui-kit/android/core-features", + "ui-kit/android/offline-support", "ui-kit/android/extensions", "ui-kit/android/ai-features" ] diff --git a/ui-kit/android/calling-integration.mdx b/ui-kit/android/calling-integration.mdx index 9213c2afd..a6ee3c7aa 100644 --- a/ui-kit/android/calling-integration.mdx +++ b/ui-kit/android/calling-integration.mdx @@ -39,7 +39,7 @@ The UI Kit does not bundle the Calls SDK: `calls-sdk-android` is a compile-only ```kotlin build.gradle.kts dependencies { - implementation("com.cometchat:chatuikit-kotlin-android:6.2.0") + implementation("com.cometchat:chatuikit-kotlin-android:6.3.0") implementation("com.cometchat:calls-sdk-android:5.1.0") implementation("com.cometchat:push-notifications-android:2.0.0") implementation("com.cometchat:push-notifications-calls-android:2.0.0") @@ -52,7 +52,7 @@ dependencies { ```kotlin build.gradle.kts dependencies { - implementation("com.cometchat:chatuikit-compose-android:6.2.0") + implementation("com.cometchat:chatuikit-compose-android:6.3.0") implementation("com.cometchat:calls-sdk-android:5.1.0") implementation("com.cometchat:push-notifications-android:2.0.0") implementation("com.cometchat:push-notifications-calls-android:2.0.0") diff --git a/ui-kit/android/conversations.mdx b/ui-kit/android/conversations.mdx index 502f2a689..2009c27e4 100644 --- a/ui-kit/android/conversations.mdx +++ b/ui-kit/android/conversations.mdx @@ -487,6 +487,9 @@ For pins made elsewhere, the Chat SDK exposes `CometChat.ConversationListener` w | `setTitle("Chats")` | `title = "Chats"` | Custom toolbar title | | `setSearchPlaceholderText("Search...")` | `searchPlaceholderText = "Search..."` | Search placeholder | | `setPinConversationOptionVisibility(View.GONE)` | `hidePinOption = true` | Hide the built-in Pin/Unpin conversation option | +| `setHideOfflineNotices(true)` | `hideOfflineNotices = true` | Hide the offline notice toasts, such as unsent messages that were lost (default `false`). Offline support only, from v6.3.0 | + +With [offline support](/ui-kit/android/offline-support#lists-conversations-users-groups-and-group-members) on, the list shows saved conversations first, and **Connect to load chats** when nothing is saved and there is no connection. A chat whose last message is your own unsent message shows a clock, or a failed icon once sending failed. --- diff --git a/ui-kit/android/core-features.mdx b/ui-kit/android/core-features.mdx index 7f50bf8a4..f9f6ddd67 100644 --- a/ui-kit/android/core-features.mdx +++ b/ui-kit/android/core-features.mdx @@ -9,7 +9,7 @@ description: "Overview of CometChat's core chat features including instant messa | --- | --- | | Packages | `com.cometchat:chatuikit-kotlin-android` (Kotlin XML Views), `com.cometchat:chatuikit-compose-android` (Jetpack Compose) | | Required setup | `CometChatUIKit.init()` then `CometChatUIKit.login()` — must complete before rendering any component | -| Core features | Instant Messaging, Media Sharing, Read Receipts, Mark as Unread, Typing Indicator, User Presence, Reactions, Mentions, Rich Text Formatting, Quoted Reply, Search, Threaded Conversations, Moderation, Report Message, Group Chat | +| Core features | Instant Messaging, Media Sharing, Read Receipts, Mark as Unread, Typing Indicator, User Presence, Reactions, Mentions, Rich Text Formatting, Quoted Reply, Search, Threaded Conversations, Moderation, Report Message, Group Chat, Offline Support | | Key components | `CometChatConversations`, `CometChatMessageList`, `CometChatMessageComposer`, `CometChatMessageHeader`, `CometChatUsers`, `CometChatGroups`, `CometChatGroupMembers`, `CometChatMessageInformation`, `CometChatThreadHeader` | | Theming | See [Theming](/ui-kit/android/theme-introduction) | @@ -290,6 +290,26 @@ Conversation and Advanced Search enables users to quickly find conversations, me | [CometChatMessageList](/ui-kit/android/message-list) | Shows the selected message when clicked from search results and highlights it in the message list. | | [CometChatConversations](/ui-kit/android/conversations) | Displays the search input. | +## Offline Support + +*Available since v6.3.0* + +Show chats the user has opened before without a connection, and queue text messages and voice notes sent offline until the connection returns. Lists show their saved rows first, unsent messages offer Retry and Delete, and every screen shows a clear "Connect to load …" state when it has nothing saved. Offline support is off by default. Turn it on in `UIKitSettings`; the code is the same for both kits: + +```kotlin lines +import com.cometchat.chat.core.OfflineConfig +import com.cometchat.uikit.core.UIKitSettings + +val uiKitSettings = UIKitSettings.UIKitSettingsBuilder() + .setRegion("REGION") + .setAppId("APP_ID") + .setAuthKey("AUTH_KEY") + .setOfflineConfig(OfflineConfig.Builder().enabled(true).build()) + .build() +``` + +UI Kit 6.3.0 brings in Chat SDK 5.1.2. See [Offline Support](/ui-kit/android/offline-support) for requirements, component behaviour, texts, styling and events. + --- ## Next Steps diff --git a/ui-kit/android/events.mdx b/ui-kit/android/events.mdx index 20e251557..a5ccac8c3 100644 --- a/ui-kit/android/events.mdx +++ b/ui-kit/android/events.mdx @@ -10,7 +10,7 @@ description: "Listen to UI Kit events for user actions, group changes, messages, | Kotlin (XML Views) | `com.cometchat:chatuikit-kotlin-android` | | Jetpack Compose | `com.cometchat:chatuikit-compose-android` | | Import | `com.cometchat.uikit.core.events.CometChatEvents` | -| Event flows | `CometChatEvents.messageEvents`, `CometChatEvents.callEvents`, `CometChatEvents.conversationEvents`, `CometChatEvents.groupEvents`, `CometChatEvents.userEvents`, `CometChatEvents.uiEvents` | +| Event flows | `CometChatEvents.messageEvents`, `CometChatEvents.callEvents`, `CometChatEvents.conversationEvents`, `CometChatEvents.groupEvents`, `CometChatEvents.userEvents`, `CometChatEvents.uiEvents`, `CometChatEvents.offlineEvents` (offline support only) | | Pattern | Kotlin `SharedFlow` with sealed class event types — collect in `viewModelScope` or `lifecycleScope` | | Purpose | Decoupled communication between UI Kit components — subscribe to event flows to react to changes without direct component references | @@ -51,6 +51,7 @@ import com.cometchat.uikit.core.events.CometChatMessageEvent | `CometChatEvents.userEvents` | `UserEvent` | User blocked, unblocked | | `CometChatEvents.uiEvents` | `UIEvent` | Panel visibility, active chat changes | | `CometChatEvents.threadEvents` | `CometChatThreadEvent` | Thread subscription state changes | +| `CometChatEvents.offlineEvents` | `CometChatOfflineEvent` | Own message send state changes and offline cache resets. Only with [offline support](/ui-kit/android/offline-support#offline-events) on | ## API reference @@ -183,6 +184,17 @@ lifecycleScope.launch { See [Threaded Messages → Thread Subscription](/ui-kit/android/guide-threaded-messages#thread-subscription) for the feature end to end. +### Offline Events + +`CometChatEvents.offlineEvents` emits `CometChatOfflineEvent` instances while [offline support](/ui-kit/android/offline-support) is on. It never emits while offline support is off. + +| Event | Description | +| ----- | ----------- | +| `CometChatOfflineEvent.MessageSendStateChanged(message, state, reason)` | One of your own messages moved to `SENDING`, `SENT` or `FAILED`. `reason` is the Chat SDK's `MessageFailureReason` when it failed. | +| `CometChatOfflineEvent.OfflineCacheReset(reason, pendingMessagesLost)` | The Chat SDK reset its offline cache. `pendingMessagesLost` is `-1` when the number is unknown. | + +See [Offline events](/ui-kit/android/offline-support#offline-events) for a collection example in both kits. + ### Call Events `CometChatEvents.callEvents` emits `CallEvent` sealed class instances for call lifecycle changes. diff --git a/ui-kit/android/getting-started-jetpack.mdx b/ui-kit/android/getting-started-jetpack.mdx index db1a0d9b2..4ee317ca7 100644 --- a/ui-kit/android/getting-started-jetpack.mdx +++ b/ui-kit/android/getting-started-jetpack.mdx @@ -16,6 +16,7 @@ description: "Step-by-step guide to integrate the CometChat Jetpack Compose UI K | Auth Key | Dev/testing only. Use Auth Token in production | | Calling | Optional. `setEnableCalling(true)` in `UIKitSettings` + push ringing setup. Your app adds `com.cometchat:calls-sdk-android` (the UI Kit does not bundle it); push ringing adds the Push Notifications SDK and Firebase Messaging | | Min SDK | Android 9.0 (API 28) | +| Offline support | Optional, off by default, from UI Kit 6.3.0. `setOfflineConfig(OfflineConfig)` on the `UIKitSettings` builder before `build()`. See [Offline Support](/ui-kit/android/offline-support) | @@ -116,7 +117,7 @@ dependencies { implementation("androidx.compose.material3:material3") // CometChat Jetpack Compose UI Kit - implementation("com.cometchat:chatuikit-compose-android:6.2.0") + implementation("com.cometchat:chatuikit-compose-android:6.3.0") // Voice/video calling: the UI Kit does not bundle the Calls SDK, so add it here. Incoming // calls ring through the Push Notifications SDK and Firebase Messaging, added in Calling Integration. implementation("com.cometchat:calls-sdk-android:5.1.0") @@ -128,7 +129,7 @@ dependencies { -**Don't force Compose 1.7.** `chatuikit-compose-android` 6.2.0 calls a Compose 1.8 `LazyColumn` API. Its POM declares compose-bom 2024.09.00 (Compose 1.7), but its `cards-android` 1.0.0 dependency brings compose-bom 2025.04.01, so a normal build resolves Compose 1.8 and works. If you force Compose 1.7 — a `strictly` version constraint, an `enforcedPlatform(...)` BOM older than 2025.04.01, or a resolution strategy — the app builds, then crashes with `NoSuchMethodError: ... LazyColumn(...)` when `CometChatConversations` first renders. Keep the app's BOM at 2025.04.01 or newer, as above. +**Don't force Compose 1.7.** `chatuikit-compose-android` 6.2.0 and later call a Compose 1.8 `LazyColumn` API. Its POM declares compose-bom 2024.09.00 (Compose 1.7), but its `cards-android` 1.0.0 dependency brings compose-bom 2025.04.01, so a normal build resolves Compose 1.8 and works. If you force Compose 1.7 — a `strictly` version constraint, an `enforcedPlatform(...)` BOM older than 2025.04.01, or a resolution strategy — the app builds, then crashes with `NoSuchMethodError: ... LazyColumn(...)` when `CometChatConversations` first renders. Keep the app's BOM at 2025.04.01 or newer, as above. --- @@ -242,6 +243,10 @@ class MainActivity : ComponentActivity() { `init()` must resolve before you call `login()`. Calling `login()` before init completes will fail silently. + +To let users open saved chats and queue messages without a connection, add `.setOfflineConfig(OfflineConfig.Builder().enabled(true).build())` to the `UIKitSettings` builder before `.build()`. Offline support is off by default and is available from UI Kit 6.3.0. See [Offline Support](/ui-kit/android/offline-support). + + --- ## Step 4 — Choose a Chat Experience diff --git a/ui-kit/android/getting-started-kotlin.mdx b/ui-kit/android/getting-started-kotlin.mdx index 78d8da3be..a514d6249 100644 --- a/ui-kit/android/getting-started-kotlin.mdx +++ b/ui-kit/android/getting-started-kotlin.mdx @@ -16,6 +16,7 @@ description: "Step-by-step guide to integrate the CometChat Kotlin UI Kit with X | Auth Key | Dev/testing only. Use Auth Token in production | | Calling | Optional. `setEnableCalling(true)` in `UIKitSettings` + push ringing setup. Your app adds `com.cometchat:calls-sdk-android` (the UI Kit does not bundle it); push ringing adds the Push Notifications SDK and Firebase Messaging | | Min SDK | Android 9.0 (API 28) | +| Offline support | Optional, off by default, from UI Kit 6.3.0. `setOfflineConfig(OfflineConfig)` on the `UIKitSettings` builder before `build()`. See [Offline Support](/ui-kit/android/offline-support) | @@ -112,7 +113,7 @@ kotlin { dependencies { // CometChat Kotlin UI Kit - implementation("com.cometchat:chatuikit-kotlin-android:6.2.0") + implementation("com.cometchat:chatuikit-kotlin-android:6.3.0") // Voice/video calling: the UI Kit does not bundle the Calls SDK, so add it here. Incoming // calls ring through the Push Notifications SDK and Firebase Messaging, added in Calling Integration. implementation("com.cometchat:calls-sdk-android:5.1.0") @@ -125,7 +126,7 @@ dependencies { ### Add AndroidX Support -UI Kit 6.2.0 builds without Jetifier, so you don't need `android.enableJetifier`. Set it in `gradle.properties` only if another dependency of yours still uses the legacy support libraries; AGP 9 deprecates it and logs a warning: +UI Kit 6.2.0 and later build without Jetifier, so you don't need `android.enableJetifier`. Set it in `gradle.properties` only if another dependency of yours still uses the legacy support libraries; AGP 9 deprecates it and logs a warning: ```properties gradle.properties android.enableJetifier=true @@ -229,6 +230,10 @@ class MainActivity : AppCompatActivity() { `init()` must resolve before you call `login()`. Calling `login()` before init completes will fail silently. + +To let users open saved chats and queue messages without a connection, add `.setOfflineConfig(OfflineConfig.Builder().enabled(true).build())` to the `UIKitSettings` builder before `.build()`. Offline support is off by default and is available from UI Kit 6.3.0. See [Offline Support](/ui-kit/android/offline-support). + + --- ## Step 4 — Choose a Chat Experience diff --git a/ui-kit/android/getting-started.mdx b/ui-kit/android/getting-started.mdx index 147e422b2..9cb80eb2b 100644 --- a/ui-kit/android/getting-started.mdx +++ b/ui-kit/android/getting-started.mdx @@ -17,6 +17,7 @@ description: "Install, configure, and launch the CometChat Android UI Kit in you | Theme | Set `CometChatTheme.DayNight` as parent theme in `themes.xml` | | Calling | Optional. `setEnableCalling(true)` in `UIKitSettings` + push ringing setup. Your app adds `com.cometchat:calls-sdk-android` (the UI Kit does not bundle it); push ringing adds the Push Notifications SDK and Firebase Messaging | | Min SDK | Android 9.0 (API 28) | +| Offline support | Optional, off by default, from UI Kit 6.3.0. `setOfflineConfig(OfflineConfig)` on the `UIKitSettings` builder before `build()`. See [Offline Support](/ui-kit/android/offline-support) | @@ -88,7 +89,7 @@ Inside `libs.versions.toml`, add the versions: ```toml libs.versions.toml [versions] -cometchat-ui-kit = "6.2.0" +cometchat-ui-kit = "6.3.0" cometchat-calls-sdk = "5.1.0" # for calling; the UI Kit does not bundle it ``` @@ -137,7 +138,7 @@ Open the app-level `build.gradle.kts` file and add the dependency for your chose ```kotlin build.gradle.kts dependencies { - implementation("com.cometchat:chatuikit-kotlin-android:6.2.0") + implementation("com.cometchat:chatuikit-kotlin-android:6.3.0") // Calling: the UI Kit does not bundle the Calls SDK; push ringing is added in Calling Integration implementation("com.cometchat:calls-sdk-android:5.1.0") } @@ -151,7 +152,7 @@ dependencies { implementation(platform("androidx.compose:compose-bom:2025.06.00")) implementation("androidx.compose.material3:material3") - implementation("com.cometchat:chatuikit-compose-android:6.2.0") + implementation("com.cometchat:chatuikit-compose-android:6.3.0") // Calling: the UI Kit does not bundle the Calls SDK; push ringing is added in Calling Integration implementation("com.cometchat:calls-sdk-android:5.1.0") } @@ -164,7 +165,7 @@ dependencies { ### Add AndroidX Support -UI Kit 6.2.0 builds without Jetifier, so you don't need `android.enableJetifier`. Set it in `gradle.properties` only if another dependency of yours still uses the legacy support libraries; AGP 9 deprecates it and logs a warning: +UI Kit 6.2.0 and later build without Jetifier, so you don't need `android.enableJetifier`. Set it in `gradle.properties` only if another dependency of yours still uses the legacy support libraries; AGP 9 deprecates it and logs a warning: ```properties gradle.properties android.enableJetifier=true diff --git a/ui-kit/android/guide-pin-and-save-messages.mdx b/ui-kit/android/guide-pin-and-save-messages.mdx index 3bab31a1c..8dc58385c 100644 --- a/ui-kit/android/guide-pin-and-save-messages.mdx +++ b/ui-kit/android/guide-pin-and-save-messages.mdx @@ -177,7 +177,7 @@ The limit and system-pin codes are also listed in the [Error Guide](/articles/er ## Live Updates -On the acting user's device, all surfaces stay in sync through the UI Kit event bus — pinning from the action sheet updates the bubble indicator and the Pinned Messages screen without a refetch. Delivery of message pin/save events to other participants and to the user's other devices activates once server-side real-time delivery for these features is rolled out; until then, other clients pick the change up on their next fetch. If you build custom UI, observe the `MessagePinned` / `MessageUnpinned` / `MessageSaved` / `MessageUnsaved` events; see [Events](/ui-kit/android/events). +On the acting user's device, all surfaces stay in sync through the UI Kit event bus — pinning from the action sheet updates the bubble indicator and the Pinned Messages screen without a refetch. The UI Kit makes these updates, and raises its events, when the pin or save call succeeds (its `onSuccess`): with Chat SDK 5.1.2 the SDK sends no listener event back to the device that made the change. Delivery of message pin/save events to other participants and to the user's other devices activates once server-side real-time delivery for these features is rolled out; until then, other clients pick the change up on their next fetch. If you build custom UI, observe the `MessagePinned` / `MessageUnpinned` / `MessageSaved` / `MessageUnsaved` events; see [Events](/ui-kit/android/events). ## Summary / Feature Matrix diff --git a/ui-kit/android/llms-android-v6.mdx b/ui-kit/android/llms-android-v6.mdx index db8d2aa8c..6d5995955 100644 --- a/ui-kit/android/llms-android-v6.mdx +++ b/ui-kit/android/llms-android-v6.mdx @@ -18,8 +18,8 @@ description: "Machine-readable, Android-v6-scoped index of every UI Kit page as # Android UI Kit v6 — LLM docs index (Latest) > Stateful, drop-in Android chat/calling UI. Two UI flavors of ONE kit: -> `com.cometchat:chatuikit-kotlin-android:6.2.0` (Kotlin, XML Views) and -> `com.cometchat:chatuikit-compose-android:6.2.0` (Jetpack Compose) — both pull in +> `com.cometchat:chatuikit-kotlin-android:6.3.0` (Kotlin, XML Views) and +> `com.cometchat:chatuikit-compose-android:6.3.0` (Jetpack Compose) — both pull in > `com.cometchat:chat-sdk-android` 5.x transitively; calling adds `com.cometchat:calls-sdk-android:5.1.0`. This page is an **Android-v6-only** routing index for AI > agents — a scoped alternative to the site-wide `/docs/llms.txt`. @@ -36,7 +36,7 @@ there. split into two dedicated pages (linked below). ## Install facts an agent must not guess -- **Latest versions:** UI Kit `6.2.0` (`chatuikit-kotlin-android` or `chatuikit-compose-android` — +- **Latest versions:** UI Kit `6.3.0` (`chatuikit-kotlin-android` or `chatuikit-compose-android` — one, not both), Calls SDK `com.cometchat:calls-sdk-android:5.1.0` (optional, only for voice/video). Don't add `chat-sdk-android` yourself; the kit brings it in. - Repository: `maven("https://dl.cloudsmith.io/public/cometchat/cometchat/maven/")` in @@ -70,6 +70,7 @@ attributes, long-tail components, theming tokens, or feature enablement. ## Core & configuration - [Core Features](/ui-kit/android/core-features) +- [Offline Support](/ui-kit/android/offline-support) — off by default; `setOfflineConfig(...)` on the `UIKitSettings` builder (UI Kit 6.3.0+) - [Extensions](/ui-kit/android/extensions) - [Smart / AI Features](/ui-kit/android/ai-features) - [Call Features](/ui-kit/android/call-features) diff --git a/ui-kit/android/localize.mdx b/ui-kit/android/localize.mdx index acd27484c..1a29eccc4 100644 --- a/ui-kit/android/localize.mdx +++ b/ui-kit/android/localize.mdx @@ -104,6 +104,8 @@ Override any UI Kit string by adding the same key to your app's `res/values/stri This works identically for both Kotlin XML Views and Jetpack Compose — both modules read from the same Android string resources. +The texts that [offline support](/ui-kit/android/offline-support) shows, such as "Connect to load chats", "Not sent yet" and "Jump to latest", are listed with their keys in [Offline states and texts](/ui-kit/android/offline-support#offline-states-and-texts). Override them the same way. + --- ## Customize Date & Time Labels diff --git a/ui-kit/android/message-composer.mdx b/ui-kit/android/message-composer.mdx index be79a7075..3db6e3295 100644 --- a/ui-kit/android/message-composer.mdx +++ b/ui-kit/android/message-composer.mdx @@ -201,6 +201,10 @@ Limits are governed by the app's server settings (CometChat dashboard) — the c Each tile carries an `AttachmentUploadStatus` (`UPLOADING`, `DONE`, `FAILED`, `REJECTED`, `CANCELLED`) mapped directly from the SDK's per-file upload callbacks, so the tray shows the right affordance — cancel while uploading, **retry** on a `FAILED` (transient) tile, **remove** on a `REJECTED` (non-retryable) tile. Errors surface through the composer ViewModel's `errorEvent`, which you can observe to show your own snack bar. +### Sending while offline + +With [offline support](/ui-kit/android/offline-support#composer-and-unsent-messages) on, text messages and voice notes sent without a connection are queued and go out when the connection returns. Files staged in the tray still need a connection to upload, so they aren't queued. The tray keeps them for that chat, so they come back when the chat is opened again. Send files from the tray while connected. + ### Disabling Multiple Attachments Set the flag to `false` to restore the legacy behavior — single-item pickers that send immediately with no tray: diff --git a/ui-kit/android/message-list.mdx b/ui-kit/android/message-list.mdx index 850bc3e3c..b21edf40d 100644 --- a/ui-kit/android/message-list.mdx +++ b/ui-kit/android/message-list.mdx @@ -280,6 +280,8 @@ The component listens to SDK message events internally. No manual setup needed. | `setOnThreadRepliesClick { }` | `onThreadRepliesClick = { }` | Thread reply tap callback | | `setThreaded(true)` | `threaded = true` | Mark the list as a thread view: a missing or invalid parent message shows the empty state instead of the whole conversation. A valid `setParentMessageId` / `setParentMessage` marks it threaded automatically (from v6.1.1) | | `setEnableMultipleAttachments(true)` | `enableMultipleAttachments = true` | Render multi-attachment messages with per-type bubbles and batch grouping (default `true`). See [Multiple Attachments](#multiple-attachments) | +| `setHideOfflineNotices(true)` | `hideOfflineNotices = true` | Hide the offline notice toasts (default `false`). Offline support only, from v6.3.0. See [Offline Support](#offline-support) | +| `setOfflineRowStyle(style)` | `offlineRowStyle = style` | Style the "Not sent yet" and "Not sent. Tap to retry" lines under unsent messages. Offline support only, from v6.3.0 | --- @@ -316,6 +318,14 @@ Setting it to `false` renders every media message with the classic single-attach --- +## Offline Support + +*Available since v6.3.0* + +With [offline support](/ui-kit/android/offline-support#message-list-and-threads) on, the list (and a thread's replies) shows saved history at once, then updates it from the server. Own messages that aren't sent yet show **Not sent yet** or **Not sent. Tap to retry**, and offer only **Retry**, **Delete** and, for text, **Copy**. At the end of the saved messages with no connection, the list shows **Connect to load more**. Use `setHideOfflineNotices` / `hideOfflineNotices` to hide the offline notice toasts, and `setOfflineRowStyle` / `offlineRowStyle` to style the unsent-message lines. See [Customization](/ui-kit/android/offline-support#customization). + +--- + ## Custom View Slots ### Header View diff --git a/ui-kit/android/message-template.mdx b/ui-kit/android/message-template.mdx index 70e9394e2..716dae781 100644 --- a/ui-kit/android/message-template.mdx +++ b/ui-kit/android/message-template.mdx @@ -6,7 +6,7 @@ description: "Customize message bubble structure, layout, and behavior with Bubb **Renamed in v6.** v5's `MessageTemplate` API (`CometChatMessageTemplate`, `setTemplates`, `setType`, `setCategory`, `setBubbleView`, `setMessageReceipt`) **does not ship** in -`com.cometchat:chatuikit-kotlin-android:6.2.0` — verified against the published artifact. Bubble +`com.cometchat:chatuikit-kotlin-android:6.3.0` — verified against the published artifact. Bubble customization is now `BubbleFactory`. If you are migrating, see [Upgrading from v5](/ui-kit/android/upgrading-from-v5). diff --git a/ui-kit/android/methods.mdx b/ui-kit/android/methods.mdx index 67a6bc879..c7c7ed8f4 100644 --- a/ui-kit/android/methods.mdx +++ b/ui-kit/android/methods.mdx @@ -15,6 +15,7 @@ description: "Use CometChatUIKit wrapper methods for initialization, authenticat | Login (prod) | `CometChatUIKit.loginWithAuthToken("AUTH_TOKEN", callback)` | | Other methods | `CometChatUIKit.logout()`, `CometChatUIKit.getLoggedInUser()`, `CometChatUIKit.createUser(user, callback)` | | Send messages | `CometChatUIKit.sendTextMessage()`, `CometChatUIKit.sendMediaMessage()`, `CometChatUIKit.sendCustomMessage()` | +| Offline support | `setOfflineConfig(OfflineConfig)` on the `UIKitSettings` builder before `build()`. Off by default. See [Offline Support](/ui-kit/android/offline-support) | | Note | Use these wrapper methods instead of raw SDK calls — they manage internal UI Kit eventing | @@ -77,6 +78,7 @@ The `UIKitSettings` is an important parameter of the `init()` function. It serve | **setEnableCalling** | `Boolean` | Turns on calling: the UI Kit initialises the Calls SDK during `init()` and logs the user into it during `login()`. Default `false`. See [Calling Integration](/ui-kit/android/calling-integration) | | **setCallSettingsBuilder** | `Any` (a `CometChatCalls.SessionSettingsBuilder`) | Default session settings for the call screens. Typed `Any` so the UI Kit compiles without the Calls SDK, which your app adds | | **setEnableThreadSubscription** | `Boolean` | *Deprecated in v6.1.0.* Global switch for the thread subscription feature. Default `true` from v6.1.0 (`false` on v6.0.x, where it is the opt-in). Kept as the only app-wide opt-out — pass `false` to turn the feature off everywhere. To hide a single surface, prefer the per-screen visibility methods. See [Thread Subscription](/ui-kit/android/guide-threaded-messages#thread-subscription) | +| **setOfflineConfig** | `OfflineConfig` | Turns on offline support by passing the Chat SDK's `OfflineConfig` to the SDK. Off unless the config has `enabled(true)`. Needs UI Kit 6.3.0 or later. See [Offline Support](/ui-kit/android/offline-support) | **Usage:** @@ -196,6 +198,10 @@ CometChatUIKit.logout(object : CometChat.CallbackListener() { > **What this does:** Ends a call in progress and cancels an outgoing call still ringing, logs out of the Chat SDK and then the Calls SDK, clears the session data and tears down the internal event system. On the Calls logout the Push Notifications SDK stops a ring still playing for the old user and unregisters the push token. Call this before logging in a different user to avoid conflicts. + +With [offline support](/ui-kit/android/offline-support) on, logout also ends the user's offline session. The Chat SDK deletes the user's offline cache, the UI Kit clears the screens on display, and messages still waiting to be sent are discarded. A pending `sendTextMessage`, `sendMediaMessage` or `sendCustomMessage` calls `onError` once with `ERROR_OFFLINE_MESSAGE_DISCARDED`. + + Use `CometChatUIKit.logout`, not `CometChat.logout`. The Chat SDK's logout alone leaves the Calls SDK signed in: a ringing call is not stopped and later declines go out with the old user's token. @@ -319,6 +325,10 @@ CometChatUIKit.init(context, uiKitSettings, object : CometChat.CallbackListener< ### Base Message + +With [offline support](/ui-kit/android/offline-support) on, `sendTextMessage`, `sendMediaMessage` and `sendCustomMessage` queue the message when there is no connection. It shows in the message list at once and is sent when the connection returns. A queued send calls neither `onSuccess` nor `onError` until it is sent or fails. See [Send completions](/ui-kit/android/offline-support#send-completions). + + #### Text Message To send a text message to a single user or a group, use the `sendTextMessage()` function. This function requires a `TextMessage` object as its argument, which contains the necessary information for delivering the message. diff --git a/ui-kit/android/offline-support.mdx b/ui-kit/android/offline-support.mdx new file mode 100644 index 000000000..76016196b --- /dev/null +++ b/ui-kit/android/offline-support.mdx @@ -0,0 +1,439 @@ +--- +title: "Offline Support" +sidebarTitle: "Offline Support" +description: "Turn on offline support in the CometChat Android UI Kit so saved chats open without a connection, messages queue until reconnect, and every list shows clear offline states." +--- + + + +| Field | Value | +| --- | --- | +| Default | Off. Nothing changes until you pass an `OfflineConfig` with `enabled(true)` | +| Enable | `UIKitSettings.UIKitSettingsBuilder().setOfflineConfig(OfflineConfig.Builder().enabled(true).build())` before `build()`, then `CometChatUIKit.init()` | +| Kits | Both: `com.cometchat:chatuikit-kotlin-android` and `com.cometchat:chatuikit-compose-android`, 6.3.0 or later | +| Chat SDK | `com.cometchat:chat-sdk-android` 5.1.2 (brought in by the UI Kit) | +| Encryption | Optional: `encryption(true)` on `OfflineConfig`, and your app adds `net.zetetic:sqlcipher-android:4.13.0` | +| `OfflineConfig` options | [Android SDK offline reference](/sdk/android/v5/offline-reference) | +| Hide notices | Kotlin: `setHideOfflineNotices(true)` on `CometChatMessageList` and `CometChatConversations`. Compose: `hideOfflineNotices = true` | +| Style | Kotlin: `CometChatMessageList.setOfflineRowStyle(...)`. Compose: `CometChatMessageList(offlineRowStyle = ...)` | +| Events | `CometChatEvents.offlineEvents`: `CometChatOfflineEvent.MessageSendStateChanged`, `CometChatOfflineEvent.OfflineCacheReset` | +| Discarded send | `CometChatUIKit.sendTextMessage` / `sendMediaMessage` / `sendCustomMessage` call `onError` with `ERROR_OFFLINE_MESSAGE_DISCARDED` on logout, user switch or cache reset | + + + +With offline support turned on, the Android UI Kit reads from the Chat SDK's on-device cache. Chats the user has opened before appear at once, even with no connection. Text messages and voice notes sent while offline wait in a queue and go out when the connection returns. Every list shows a clear state when it has nothing saved and can't reach the server. + +Both kits get the same behaviour: Kotlin (XML Views) and Jetpack Compose. Where the API differs, this page shows a tab for each. The UI Kit builds on the Chat SDK's offline support, and this page covers what the UI Kit adds on top. For cache settings, encryption, media caching and sync, see the [Android SDK offline docs](/sdk/android/v5/offline-overview). + +## Overview + +**Works offline:** +- Conversations, users, groups and group members you have loaded before show at once from the cache. +- Saved message history, including threads, opens without a connection. +- New text messages and voice notes are queued and sent automatically on reconnect. So are messages sent with `CometChatUIKit.sendTextMessage`, `sendMediaMessage` and `sendCustomMessage`. A queued message shows a clock and **Not sent yet** until it is sent. +- Images, videos, audio and files that are on the device open from the saved copy. +- After a reconnect, the Chat SDK's catch-up brings in what changed while the user was away. + +**Needs a connection:** +- The first load of any chat or list that was never opened before. +- Keyword search with no saved match. +- Uploading photos, videos, audio files or documents picked in the composer's attachment tray (`enableMultipleAttachments`, on by default). The message can be sent once its files have uploaded. +- Editing or deleting a sent message, adding or removing a reaction, and pinning or saving a message. These aren't queued. +- Message information, call logs, calls and AI Assistant chat history. +- Media that has no copy on the device. + +## Requirements + +| Requirement | Version | +| --- | --- | +| CometChat Android UI Kit (`chatuikit-kotlin-android` or `chatuikit-compose-android`) | 6.3.0 or later | +| CometChat Android Chat SDK (`chat-sdk-android`) | 5.1.2, brought in by the UI Kit | +| SQLCipher (`net.zetetic:sqlcipher-android`) | 4.13.0, only if you turn on encryption | +| Android | `minSdk` 28 | + +UI Kit 6.3.0 is the first version with offline support. It brings in Chat SDK 5.1.2, so don't add `chat-sdk-android` yourself. Add the kit you use: + + + + +```kotlin build.gradle.kts +dependencies { + implementation("com.cometchat:chatuikit-kotlin-android:6.3.0") +} +``` + + + + +```kotlin build.gradle.kts +dependencies { + implementation("com.cometchat:chatuikit-compose-android:6.3.0") +} +``` + + + + +To encrypt the cache, also add the SQLCipher engine. The Chat SDK and the UI Kit don't bundle it: + +```kotlin build.gradle.kts +dependencies { + implementation("net.zetetic:sqlcipher-android:4.13.0") +} +``` + + +If you call `encryption(true)` without adding SQLCipher, the cache doesn't open and the app works online only (the default `encryptionFailureBehavior`). See [Encrypt the Cache](/sdk/android/v5/offline-encryption). + + +## Enable offline support + +Offline support is **off by default**. Turn it on by passing an `OfflineConfig` to `setOfflineConfig()` on the `UIKitSettings` builder, before you call `build()` and `CometChatUIKit.init()`. The UI Kit passes the config straight to the Chat SDK and stores nothing of its own. The code is the same for both kits. + +```kotlin lines +import com.cometchat.chat.core.CometChat +import com.cometchat.chat.core.OfflineConfig +import com.cometchat.chat.exceptions.CometChatException +import com.cometchat.uikit.core.CometChatUIKit +import com.cometchat.uikit.core.UIKitSettings + +// Offline support is off unless the config has enabled(true). +val offlineConfig = OfflineConfig.Builder() + .enabled(true) + // .encryption(true) // needs net.zetetic:sqlcipher-android in your app + .build() + +val uiKitSettings = UIKitSettings.UIKitSettingsBuilder() + .setRegion("REGION") // Replace with your App Region + .setAppId("APP_ID") // Replace with your App ID + .setAuthKey("AUTH_KEY") // Replace with your Auth Key (dev only) + .subscribePresenceForAllUsers() + .setOfflineConfig(offlineConfig) + .build() + +CometChatUIKit.init(context, uiKitSettings, object : CometChat.CallbackListener() { + override fun onSuccess(s: String) { + // Log in, then show the UI Kit screens as usual. + } + + override fun onError(e: CometChatException?) { + Log.e(TAG, "Initialization failed: ${e?.message}") + } +}) +``` + +`OfflineConfig` has more options, such as cache size, retention, the pending-message limit, encryption and media caching. Set only the ones you need. Every option is described in the [Configuration & API Reference](/sdk/android/v5/offline-reference#offlineconfig-options). + + +Offline support is active only while a user is logged in. Call `CometChat.isOfflineEnabled()` at the moment you need to know. See [Enable Offline Support](/sdk/android/v5/offline-enable). + + +When the user is already logged in, `CometChatUIKit.login()` with the same UID answers at once from the saved session, without a network call. So an app that calls `login()` on every launch still opens offline after a restart. + +## How the components behave offline + +### Lists: Conversations, Users, Groups and Group Members + +- Saved rows show first. The server page then loads and updates the list in place. +- Rows already on screen stay when a load can't reach the server. A failure caused by having no connection shows no error view. +- With nothing saved and no connection, the list shows **Connect to load chats** (or users, groups, members). This state has no Retry button. The list loads by itself when the connection returns. +- A list opened with a filter but no keyword, such as online users, behaves like a plain list and shows **Connect to load …**. +- Only an empty page from the server ends paging. +- In the conversation list, a chat whose last message is your own unsent message shows a clock, or a failed icon once sending failed. + +### Search + +A **keyword** search in a list with no saved match while offline shows **Connect to search** with a second line, **Search needs an internet connection.** It doesn't call `onError`. When the connection returns, the search runs again. + +`CometChatSearch` shows the same **Connect to search** state when its search can't reach the server and nothing saved matches. A search showing that state runs again when the connection returns. + +Mention suggestions in the composer show saved users or members first. Typing a name after the `@` needs a connection. + +### Message list and threads + +- Saved history shows at once. Older and newer pages come from the cache first, then from the server. +- A chat that was never saved, opened offline, shows **Connect to load messages** and calls `onError`. It loads by itself when the connection returns. +- When the list reaches the end of the saved messages with no connection, it shows **Connect to load more** at that edge. Tap it to try again. On reconnect, each blocked edge loads once by itself, older first. +- Jumping to a message, or starting from the first unread message, opens the list around that message from the cache when the device is offline. +- When a refresh after reconnecting brings newer messages while the user is scrolled up, a **Jump to latest** pill appears. The reading position stays until the user taps it or scrolls to the bottom. +- Images, videos, audio and files show the on-device copy first. With no copy and no connection, the bubble shows a placeholder with the file name, size and **Media will be available when back online**. It shows the media again when the connection returns. Tapping the placeholder while connected downloads the file. + +### Composer and unsent messages + +- A text message or voice note sent while offline appears at once with a clock and **Not sent yet** under the bubble. It goes out automatically on reconnect. +- Photos, videos, audio files and documents picked in the attachment tray are **not** queued. Each file starts uploading as soon as it's picked, and uploading needs a connection, so the message can't be sent until its files have uploaded. A tile whose upload failed shows a retry control: tap it to upload that file again once you're back online. With offline support on, the files staged in a chat's tray are kept for that chat, so they come back when the chat is opened again. With `enableMultipleAttachments` set to `false`, a picked file is sent as a single media message instead, and is queued like a voice note. +- An unsent message (waiting or failed) offers only **Retry**, **Delete** and, for text, **Copy** in its long-press menu. It offers no Reply, React, Edit, Pin, Save or Message info until it has been sent. The visibility settings you use for message options still apply. +- A failed message shows **Not sent. Tap to retry** under the bubble in red. Tap that line to retry. In the Kotlin kit the failed status icon retries too; in Jetpack Compose, tapping the failed message retries it. Screen readers announce the action as "Retry". +- **Retry** asks the Chat SDK to send the queued message again. A message that failed before it was queued is sent again as a new send. While a retry waits for the connection, the message shows **Not sent yet** again. +- **Delete** removes the unsent message from the device. +- If the message is no longer waiting to be sent (for example, it was removed after you left the group), Retry and Delete remove it from the list. +- If the message is being sent at that moment, Retry and Delete change nothing and the list shows **Sending… try again in a moment**. +- A full queue shows **Too many messages waiting to send**. A file that is too big for the offline media cache shows **File too large to send offline**. A queued message that the Chat SDK removes shows **1 unsent message was removed**. + +### Presence + +While the Chat SDK isn't connected, nobody shows as online: there's no online dot in the conversations, users or group members lists, and no "Online" subtitle in the message header. Presence shows again once the SDK is connected. + +### Pinned, Saved, Reactions and Notifications + +`CometChatPinnedMessages`, `CometChatSavedMessages`, the reaction list and `CometChatNotificationFeed` follow the same rules as the other lists. Rows cached on the device show first. With nothing saved and no connection, they show **Connect to load messages**, **Connect to load reactions** or **Connect to load notifications**. The reaction list keeps its tabs visible and shows **Connect to load reactions** below them. The pinned, saved and notification screens load by themselves when the connection returns. + +### Logout and user switch + +Cached data belongs to the logged-in user. The Chat SDK deletes the user's offline cache on logout and when a different user logs in. On logout or a user switch, the UI Kit also clears every list on screen before the next user's first frame. Any message still waiting to be sent is discarded, and a pending `CometChatUIKit` send answers with `ERROR_OFFLINE_MESSAGE_DISCARDED`. See [Send completions](#send-completions). + +## Offline states and texts + +Override any of these texts by adding the same key to your app's `res/values/strings.xml`, as described in [Localize](/ui-kit/android/localize#override-ui-kit-labels). Both kits read the same string resources, and every language the UI Kit ships includes them. + +| Text | Key | Where it appears | +| --- | --- | --- | +| Connect to load chats | `cometchat_connect_to_load_chats` | `CometChatConversations` with nothing saved, offline | +| Connect to load users | `cometchat_connect_to_load_users` | `CometChatUsers` | +| Connect to load groups | `cometchat_connect_to_load_groups` | `CometChatGroups` | +| Connect to load members | `cometchat_connect_to_load_members` | `CometChatGroupMembers` | +| Connect to load messages | `cometchat_connect_to_load_messages` | `CometChatMessageList`, `CometChatPinnedMessages`, `CometChatSavedMessages` | +| Connect to load reactions | `cometchat_connect_to_load_reactions` | Reaction list | +| Connect to load notifications | `cometchat_connect_to_load_notifications` | `CometChatNotificationFeed` | +| Connect to search | `cometchat_connect_to_search` | Keyword search in a list, offline, no saved match | +| Search needs an internet connection. | `cometchat_connect_to_search_subtitle` | Second line under "Connect to search" in a list | +| Connect to search | `cometchat_connect_to_search_messages` | `CometChatSearch` | +| Search needs an internet connection. | `cometchat_connect_to_search_messages_subtitle` | Second line under "Connect to search" in `CometChatSearch` | +| Connect to load more | `cometchat_connect_to_load_more` | Message list and threads, at a blocked edge | +| Jump to latest | `cometchat_jump_to_latest` | Message list pill | +| Media will be available when back online | `cometchat_media_available_when_online` | Media placeholder | +| Not sent yet | `cometchat_message_not_sent_yet` | Under a queued or sending message | +| Not sent. Tap to retry | `cometchat_message_not_sent_tap_to_retry` | Under a failed message | +| Retry | `cometchat_offline_retry` | Long-press option on an unsent message | +| Sending… try again in a moment | `cometchat_sending_try_again` | Notice: Retry or Delete on a message being sent | +| Too many messages waiting to send | `cometchat_queue_full` | Notice: the queue is full | +| File too large to send offline | `cometchat_file_too_large_offline` | Notice: the file doesn't fit the offline media cache | +| 1 unsent message was removed | `cometchat_unsent_message_removed` | Notice: the Chat SDK removed a queued message | +| %d message was not sent / %d messages were not sent | `cometchat_messages_not_sent` (plurals) | Notice: unsent messages on screen were marked as not sent. They show **Not sent. Tap to retry** and can be retried | +| %d unsent message was lost / %d unsent messages were lost | `cometchat_unsent_messages_lost` (plurals) | Notice: unsent messages were removed when the Chat SDK reset its cache. Send them again if needed | +| Unsent messages may have been lost | `cometchat_unsent_messages_maybe_lost` | Notice: some unsent messages may not have been sent. Check the chat and send them again if needed | + +Notices show as a short toast, once each. + +## Errors and callbacks + +### When `onError` fires + +With offline support on, every list follows the same rules: + +- **Rows on screen, no connection:** the rows stay. No error view, no `onError`. +- **Rows on screen, any other error:** the rows stay. `onError` fires once if the user or your app started the load: opening the screen, a refresh, a new keyword or a jump. A reload the UI Kit starts itself after a reconnect or a cache reset stays quiet. +- **Nothing on screen, no connection:** the **Connect to load …** state shows, and `onError` fires once. +- **Nothing on screen, any other error:** the error view with Retry shows, and `onError` fires. +- **Keyword search offline with nothing saved:** **Connect to search** shows, with no `onError`. +- **Empty server answer:** the normal empty view. + +### Send completions + +`CometChatUIKit.sendTextMessage`, `sendMediaMessage` and `sendCustomMessage` answer each send once: + +- `onSuccess` fires when the server accepts the message. +- `onError` fires when sending fails for good. +- A send that is only queued (offline) calls neither. It answers when the message is sent or fails. +- If the user logs out, switches user, or the offline cache is reset before the message was sent, `onError` fires once with the error code `ERROR_OFFLINE_MESSAGE_DISCARDED`. Don't show an error for it: the message row going away is the only visible signal. + +```kotlin lines +import com.cometchat.chat.core.CometChat +import com.cometchat.chat.exceptions.CometChatException +import com.cometchat.chat.models.TextMessage +import com.cometchat.uikit.core.CometChatUIKit + +CometChatUIKit.sendTextMessage(textMessage, object : CometChat.CallbackListener() { + override fun onSuccess(sent: TextMessage) { + Log.d(TAG, "Sent: ${sent.id}") + } + + override fun onError(e: CometChatException?) { + if (e?.code == "ERROR_OFFLINE_MESSAGE_DISCARDED") { + // Logout, user switch or cache reset before it was sent. Don't show an error. + return + } + Log.e(TAG, "Send failed: ${e?.message}") + } +}) +``` + +The UI Kit's own senders (the composer, stickers and smart replies) handle this case themselves and show no error. The `MessageSent` event on `CometChatEvents.messageEvents` keeps its meaning: `IN_PROGRESS` once when the message is queued, `SUCCESS` when it is sent, and `ERROR` when it fails for good. + +### Pin and save + +Pinning, unpinning, saving and unsaving need a connection. On the device that made the change, the UI Kit updates the message, the Pinned and Saved screens and the `MessagePinned` / `MessageUnpinned` / `MessageSaved` / `MessageUnsaved` events when the call succeeds (its `onSuccess`). With Chat SDK 5.1.2, which this UI Kit brings in, the SDK sends no listener event back to that device. See [Pin & Save Messages](/ui-kit/android/guide-pin-and-save-messages#live-updates). + +### Offline events + +`CometChatEvents.offlineEvents` is a flow of `CometChatOfflineEvent`. It never emits while offline support is off. + +| Event | Fires when | +| --- | --- | +| `CometChatOfflineEvent.MessageSendStateChanged(message, state, reason)` | One of your own messages moves to a new `MessageSendState`: `SENDING`, `SENT` or `FAILED`. `reason` is the Chat SDK's `MessageFailureReason` when `state` is `FAILED`, otherwise `null`. Fires once per change. | +| `CometChatOfflineEvent.OfflineCacheReset(reason, pendingMessagesLost)` | The Chat SDK reset its on-device cache. `pendingMessagesLost` is `-1` (`OfflineCacheResetListener.PENDING_COUNT_UNKNOWN`) when the SDK can't tell how many unsent messages were lost. | + + + + +```kotlin lines +import com.cometchat.uikit.core.events.CometChatEvents +import com.cometchat.uikit.core.events.CometChatOfflineEvent + +// In an Activity or Fragment +lifecycleScope.launch { + CometChatEvents.offlineEvents.collect { event -> + when (event) { + is CometChatOfflineEvent.MessageSendStateChanged -> + Log.d(TAG, "Message ${event.message.muid} is now ${event.state}") + is CometChatOfflineEvent.OfflineCacheReset -> + Log.d(TAG, "Offline cache reset, unsent messages lost: ${event.pendingMessagesLost}") + } + } +} +``` + + + + +```kotlin lines +import com.cometchat.uikit.core.events.CometChatEvents +import com.cometchat.uikit.core.events.CometChatOfflineEvent + +@Composable +fun OfflineEventsHandler() { + LaunchedEffect(Unit) { + CometChatEvents.offlineEvents.collect { event -> + when (event) { + is CometChatOfflineEvent.MessageSendStateChanged -> + Log.d(TAG, "Message ${event.message.muid} is now ${event.state}") + is CometChatOfflineEvent.OfflineCacheReset -> + Log.d(TAG, "Offline cache reset, unsent messages lost: ${event.pendingMessagesLost}") + } + } + } +} +``` + + + + +For the Chat SDK's own reasons and error codes, see the [Configuration & API Reference](/sdk/android/v5/offline-reference#error-codes). + +## Customization + +### Unsent message caption style + +`CometChatOfflineRowStyle` styles the **Not sent yet** and **Not sent. Tap to retry** lines under unsent messages. By default they use the theme's caption text, secondary text colour and error colour. + + + + +| Property | Type | Default | +| --- | --- | --- | +| `textAppearance` | `@StyleRes Int` | Theme attribute `cometchatOfflineNotSentTextAppearance` (caption 1 regular) | +| `notSentTextColor` | `@ColorInt Int` | Theme secondary text colour | +| `failedTextColor` | `@ColorInt Int` | Theme attribute `cometchatOfflineFailedMessageTint` (error colour) | + +```kotlin lines +import com.cometchat.uikit.kotlin.presentation.messagelist.style.CometChatOfflineRowStyle + +messageList.setOfflineRowStyle( + CometChatOfflineRowStyle.default(context).copy( + notSentTextColor = Color.GRAY, + failedTextColor = Color.RED + ) +) +``` + +You can also set `cometchatOfflineNotSentTextAppearance` and `cometchatOfflineFailedMessageTint` in your app theme. + + + + +| Property | Type | Default | +| --- | --- | --- | +| `textStyle` | `TextStyle` | `CometChatTheme.typography.caption1Regular` | +| `notSentTextColor` | `Color` | `CometChatTheme.colorScheme.textColorSecondary` | +| `failedTextColor` | `Color` | `CometChatTheme.colorScheme.errorColor` | + +```kotlin lines +import com.cometchat.uikit.compose.presentation.messagelist.style.CometChatOfflineRowStyle + +CometChatMessageList( + user = user, + offlineRowStyle = CometChatOfflineRowStyle.default( + notSentTextColor = Color.Gray, + failedTextColor = Color.Red + ) +) +``` + + + + +### Hide offline notices + +Hides the offline notice toasts, such as **Too many messages waiting to send** or **Unsent messages may have been lost**. A hidden list doesn't take the notice, so another list that shows notices can show it. The **Connect to load more** row and the **Jump to latest** pill still show. Default `false`. + + + + +```kotlin lines +messageList.setHideOfflineNotices(true) +conversations.setHideOfflineNotices(true) +``` + + + + +```kotlin lines +CometChatMessageList(user = user, hideOfflineNotices = true) +CometChatConversations(hideOfflineNotices = true) +``` + + + + +### Your own empty and error views + +- If you set a custom error view (`setErrorView` / `errorView`), it shows instead of the UI Kit's **Connect to load …** state. +- If you hide the error state (`setHideErrorState(true)` / `hideErrorState = true`), no offline state shows. +- If you set a custom empty view (`setEmptyView` / `emptyView`), it shows instead of **Connect to search**. Hiding the empty state hides it. + +## With offline support turned off + +Apps that don't turn on offline support keep today's behaviour, with these exceptions in UI Kit 6.3.0: + +- **Chat SDK 5.1.2.** The UI Kit brings in Chat SDK 5.1.2, whether or not offline is on. If your unit tests stub `fetchNext(any())` or `fetchPrevious(any())` on SDK request classes such as `ConversationsRequest`, give the matcher a type: the SDK now has a second overload of these methods. +- **Kotlin reaction list error state.** A reaction list that fails to load now shows its error text, or your custom error view, below the tabs instead of an empty sheet. Jetpack Compose already did this. + +## Limitations and known issues + +- Keyword search, message information, call logs and AI Assistant chat history need a connection. +- Edits, deletes, reactions, pins and saves aren't queued. They need a connection when the user makes them. +- Files picked in the attachment tray need a connection to upload. +- Media downloaded for offline use is stored unencrypted on the device. The message cache itself can be encrypted. See [Encrypt the Cache](/sdk/android/v5/offline-encryption). + +## Next steps + + + + How the Chat SDK caches and syncs data + + + Every `OfflineConfig` option, listener and error code + + + The SDK's queue, retry and discard + + + Catch-up after reconnect and cache resets + + + Message list properties and styling + + + Override the offline texts + + diff --git a/ui-kit/android/overview.mdx b/ui-kit/android/overview.mdx index ba3199a35..054116006 100644 --- a/ui-kit/android/overview.mdx +++ b/ui-kit/android/overview.mdx @@ -11,8 +11,9 @@ description: "Prebuilt, customizable UI components for chat & messaging, voice & | Kotlin (XML Views) | `com.cometchat:chatuikit-kotlin-android` v6.x | | Jetpack Compose | `com.cometchat:chatuikit-compose-android` v6.x | | Shared core | `chatuikit-core` (ViewModels, repositories, data sources, events) | -| Dependencies | `com.cometchat:chat-sdk-android` 5.0.7 (brought in by the UI Kit; don't add it yourself), `minSdk` 28 | +| Dependencies | `com.cometchat:chat-sdk-android` 5.1.2 (brought in by the UI Kit; don't add it yourself), `minSdk` 28 | | Calling | Optional — `com.cometchat:calls-sdk-android` | +| Offline support | Optional, off by default, from UI Kit 6.3.0 — see [Offline Support](/ui-kit/android/offline-support) | | Source | [GitHub](https://github.com/cometchat/cometchat-uikit-android) | diff --git a/ui-kit/android/troubleshooting.mdx b/ui-kit/android/troubleshooting.mdx index 8922b085d..d1b5190a3 100644 --- a/ui-kit/android/troubleshooting.mdx +++ b/ui-kit/android/troubleshooting.mdx @@ -68,7 +68,7 @@ description: "Common failure modes and fixes for the CometChat Android V6 UI Kit | `disableSoundForMessages(true)` has no effect | Called after component starts loading | Call `disableSoundForMessages(true)` before the component starts loading | | Filters not applied | Builder not set on component | Ensure you call the appropriate `set*RequestBuilder(builder)` method on the component instance after creating and configuring the builder | | ProGuard/R8 strips CometChat classes | Missing keep rules for CometChat | Add `-keep class com.cometchat.** { *; }` to your `proguard-rules.pro` file | -| Jetifier errors during build | Another dependency still uses the legacy support libraries | UI Kit 6.2.0 builds without Jetifier, so you don't need it for CometChat. Add `android.enableJetifier=true` to `gradle.properties` only if another dependency uses the legacy support libraries (AGP 9 deprecates it and logs a warning) | +| Jetifier errors during build | Another dependency still uses the legacy support libraries | UI Kit 6.2.0 and later build without Jetifier, so you don't need it for CometChat. Add `android.enableJetifier=true` to `gradle.properties` only if another dependency uses the legacy support libraries (AGP 9 deprecates it and logs a warning) | | `CometChatConversationList` not found | Component renamed in v6 | Use `CometChatConversations` instead of `CometChatConversationList` | | `CometChatThreadedMessagesHeader` not found | Component renamed in v5 | Use `CometChatThreadHeader` instead | diff --git a/ui-kit/android/upgrading-from-v5.mdx b/ui-kit/android/upgrading-from-v5.mdx index eb995fbe0..5ddc987b8 100644 --- a/ui-kit/android/upgrading-from-v5.mdx +++ b/ui-kit/android/upgrading-from-v5.mdx @@ -59,7 +59,7 @@ dependencies { ```groovy title="build.gradle" dependencies { - implementation 'com.cometchat:chatuikit-kotlin-android:6.2.0' + implementation 'com.cometchat:chatuikit-kotlin-android:6.3.0' // chatuikit-core is pulled in transitively } ``` @@ -72,7 +72,7 @@ dependencies { implementation platform('androidx.compose:compose-bom:2025.06.00') implementation 'androidx.compose.material3:material3' - implementation 'com.cometchat:chatuikit-compose-android:6.2.0' + implementation 'com.cometchat:chatuikit-compose-android:6.3.0' // chatuikit-core is pulled in transitively } ``` From 2824e0362bc5bf9410f0dd49dc864ecd0c1d4dac Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 23 Nov 2026 17:58:45 +0530 Subject: [PATCH 2/2] docs(android): calling notes apply to UI Kit 6.2.0 and later Co-Authored-By: Claude Opus 5.5 --- ui-kit/android/calling-integration.mdx | 2 +- ui-kit/android/getting-started-jetpack.mdx | 2 +- ui-kit/android/getting-started-kotlin.mdx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui-kit/android/calling-integration.mdx b/ui-kit/android/calling-integration.mdx index a6ee3c7aa..3eb148a80 100644 --- a/ui-kit/android/calling-integration.mdx +++ b/ui-kit/android/calling-integration.mdx @@ -66,7 +66,7 @@ dependencies { Apply the `google-services` plugin and put `google-services.json` in the app module. `minSdk` must be 28 or higher, the UI Kit's minimum. -**`setEnableCalling(true)` and the `calls-sdk-android` artifact are a pair.** UI Kit 6.2.0 checks for the Calls SDK during `init`: with the flag on and the artifact missing it logs `enableCalling=true but the CometChat Calls SDK is not on the classpath; skipping Calls init`, finishes chat init without calling. The calling components then fail quietly, each with its own `Calls SDK is not on the classpath` warning in logcat: Call Logs shows an empty list, the call buttons fail with `CALLS_SDK_MISSING`, and the call screen does not start. UI Kits before 6.2.0 crashed at launch with `NoClassDefFoundError` instead. The UI Kit requires `calls-sdk-android` 5.1 or newer and `push-notifications-android` / `push-notifications-calls-android` 2.0 or newer. +**`setEnableCalling(true)` and the `calls-sdk-android` artifact are a pair.** UI Kit 6.2.0 and later check for the Calls SDK during `init`: with the flag on and the artifact missing it logs `enableCalling=true but the CometChat Calls SDK is not on the classpath; skipping Calls init`, finishes chat init without calling. The calling components then fail quietly, each with its own `Calls SDK is not on the classpath` warning in logcat: Call Logs shows an empty list, the call buttons fail with `CALLS_SDK_MISSING`, and the call screen does not start. UI Kits before 6.2.0 crashed at launch with `NoClassDefFoundError` instead. The UI Kit requires `calls-sdk-android` 5.1 or newer and `push-notifications-android` / `push-notifications-calls-android` 2.0 or newer. ## Step 2: Enable calling in the UI Kit diff --git a/ui-kit/android/getting-started-jetpack.mdx b/ui-kit/android/getting-started-jetpack.mdx index 4ee317ca7..238bb282a 100644 --- a/ui-kit/android/getting-started-jetpack.mdx +++ b/ui-kit/android/getting-started-jetpack.mdx @@ -49,7 +49,7 @@ Auth Key is for development only. In production, generate Auth Tokens server-sid -**Calling.** Set `enableCalling` to `true` to turn on voice and video calling; the UI Kit then initialises the Calls SDK and logs the user into it. The UI Kit does not bundle the Calls SDK: add `com.cometchat:calls-sdk-android:5.1.0` to your app. With the flag on and the artifact missing, UI Kit 6.2.0 logs a warning at `init`, skips the Calls SDK, and the calling components fail quietly (empty call logs, call buttons failing with `CALLS_SDK_MISSING`, no call screen); UI Kits before 6.2.0 crashed at launch. Incoming calls ring through the Push Notifications SDK, which your app adds along with Firebase Messaging when it sets up push ringing. See [Calling Integration](/ui-kit/android/calling-integration). Leave the flag `false` in an app that does not use calling. +**Calling.** Set `enableCalling` to `true` to turn on voice and video calling; the UI Kit then initialises the Calls SDK and logs the user into it. The UI Kit does not bundle the Calls SDK: add `com.cometchat:calls-sdk-android:5.1.0` to your app. With the flag on and the artifact missing, UI Kit 6.2.0 and later log a warning at `init`, skips the Calls SDK, and the calling components fail quietly (empty call logs, call buttons failing with `CALLS_SDK_MISSING`, no call screen); UI Kits before 6.2.0 crashed at launch. Incoming calls ring through the Push Notifications SDK, which your app adds along with Firebase Messaging when it sets up push ringing. See [Calling Integration](/ui-kit/android/calling-integration). Leave the flag `false` in an app that does not use calling. ## Step 1 — Create an Android Project diff --git a/ui-kit/android/getting-started-kotlin.mdx b/ui-kit/android/getting-started-kotlin.mdx index a514d6249..7754177d8 100644 --- a/ui-kit/android/getting-started-kotlin.mdx +++ b/ui-kit/android/getting-started-kotlin.mdx @@ -49,7 +49,7 @@ Auth Key is for development only. In production, generate Auth Tokens server-sid -**Calling.** Set `enableCalling` to `true` to turn on voice and video calling; the UI Kit then initialises the Calls SDK and logs the user into it. The UI Kit does not bundle the Calls SDK: add `com.cometchat:calls-sdk-android:5.1.0` to your app. With the flag on and the artifact missing, UI Kit 6.2.0 logs a warning at `init`, skips the Calls SDK, and the calling components fail quietly (empty call logs, call buttons failing with `CALLS_SDK_MISSING`, no call screen); UI Kits before 6.2.0 crashed at launch. Incoming calls ring through the Push Notifications SDK, which your app adds along with Firebase Messaging when it sets up push ringing. See [Calling Integration](/ui-kit/android/calling-integration). Leave the flag `false` in an app that does not use calling. +**Calling.** Set `enableCalling` to `true` to turn on voice and video calling; the UI Kit then initialises the Calls SDK and logs the user into it. The UI Kit does not bundle the Calls SDK: add `com.cometchat:calls-sdk-android:5.1.0` to your app. With the flag on and the artifact missing, UI Kit 6.2.0 and later log a warning at `init`, skips the Calls SDK, and the calling components fail quietly (empty call logs, call buttons failing with `CALLS_SDK_MISSING`, no call screen); UI Kits before 6.2.0 crashed at launch. Incoming calls ring through the Push Notifications SDK, which your app adds along with Firebase Messaging when it sets up push ringing. See [Calling Integration](/ui-kit/android/calling-integration). Leave the flag `false` in an app that does not use calling. ## Step 1 — Create an Android Project