Product update · · 3 min read

Ready-made chat UI for Android with Jetpack Compose

Drop a chatbox and conversation list into your Compose app, with push notifications built in.

TalkJS Android Components SDK for Jetpack Compose

If your Android app is written in Kotlin with Jetpack Compose, TalkJS used to give you data, not screens: the Kotlin Data API synced users, conversations and messages, and you drew every chat screen yourself. That's a good fit when you want full control, and a lot of work when all you need is a working chat.

The TalkJS Android Components SDK 0.2.0 adds a ready-made chat UI to Jetpack Compose apps. It gives you two composables, Chatbox for a single conversation and ConversationList for a user's inbox, plus push notifications through Firebase Cloud Messaging. The Kotlin Data API is included, so one dependency covers both the UI and your chat data.

How the TalkJS Android Components SDK works

A TalkJS chat screen in Compose is one composable. This example shows the conversation my_conversation to the user frank, hides the built-in chat header so your own top bar can take its place, and loads a custom theme from your app's assets folder:

Chatbox(
    modifier = Modifier.fillMaxSize(),
    appId = "<YOUR_APP_ID>",
    userId = "frank",
    conversationId = "my_conversation",
    chatHeaderVisible = false,
    themePath = "my-theme/js/custom-theme.js",
)

Inside each composable, the Android Components SDK renders TalkJS Web Components in an Android WebView. The JavaScript and CSS ship inside the library and load from the app, not from a CDN. The upside is that the chat UI on Android matches the one on the web: if you already use the TalkJS React or Web Components SDK, you can copy your theme files into assets and point themePath and customCssPath at them. The Customization guide applies to both.

Native Android code still handles what belongs to the device. When a user records a voice message or shares a location, Android shows its system permission prompt. The beforePermissionPrompt callback lets you explain the request first, and onMissingPermission tells you when the user has said no.

Push notifications for Android chat with Firebase Cloud Messaging

The TalkJS Android Components SDK also delivers push notifications through Firebase Cloud Messaging (FCM). You call TalkJSNotifications.registerPushNotificationHandlers once from Application.onCreate, and the library registers the device with TalkJS, shows a notification when a message arrives while the user is offline, and groups notifications into one per conversation.

When the user taps a notification, the library can open the activity you pass as activityToOpen, and your onNotificationPressed callback receives the conversation ID so you can open the right chat. Channel settings such as importance, sound and lock screen visibility go in PushNotificationSettings. If your app already has its own FirebaseMessagingService, you can turn off the built-in one and forward TalkJS messages to TalkJSNotifications.handleRemoteMessage. The push notifications guide has the setup steps.

What you can build with Android Components

These are some of the screens and behaviors the TalkJS Android Components SDK supports in its first release:

Android Components FAQ

Should I use Android Components or the Kotlin Data API?

Use Android Components for a ready-made chat UI in a Compose app. Use the Kotlin Data API on its own to build a fully custom UI, or for chat logic without UI. Android Components includes the Kotlin Data API, so you can combine them, for example to create users and conversations before you show a Chatbox.

Do I need my own Firebase project for Android push notifications?

Yes. TalkJS Android Components sends push notifications through Firebase Cloud Messaging, so your app needs Firebase set up, and you add your Firebase service account key on the Settings page of the TalkJS dashboard. The push notifications guide has the steps.

Is there a TalkJS chat UI for iOS as well?

TalkJS Android Components is for Android only. For a native iOS app, the Swift Data API gives you the chat data, and you build the UI. If your app is built with Flutter or React Native, the TalkJS components for those frameworks give you a ready-made chat UI on both Android and iOS.

Get started with Android Components

Add com.talkjs:android-components version 0.2.0 from Maven Central to a Jetpack Compose app with a minimum SDK of 24 (Android 7.0). For more on Android chat with TalkJS, see Android chat with TalkJS. To set up your first chat, follow the Android getting started guide.