Android chat SDK quickstart Beta

Native Kotlin chat for Android with a Jetpack Compose kit: conversation list, chat screen, voice notes, FCM push registration and call invites that open the Titli Video SDK. Beta 0.1.0, on request.

Beta 0.1.0, on request. The Android chat SDK is not on a public Git host or package registry. To get it, open SDK downloads in the console and press Request access; after approval you download the versioned archive there, with its sha256 checksum, changelog and install steps for your App ID. You can also ask for access on WhatsApp or hello@titliapp.com. Install lines marked "after access is granted" need that archive. What was tested: emulators and macOS so far. Push notifications on real devices are not verified yet.

Set in your dashboard vs. set in code

SettingWhere
App Key, its bindings (package name, bundle ID, website, signing certificate) and Quick-mode capsDashboard: Console → Projects → Quick mode
Chat push credentials (FCM, APNs), profanity filter, recall windowDashboard: Console → Chat
Chat plan (Free, Pay as you go)Dashboard: Console → Chat
Chat token lifetimeCode: Quick mode handles it for you; with server tokens, ttl_seconds (60 to 604800 seconds)
Who the user is (user id, display name)Code: init / setUser in the app

Quick mode: add your App Key, chat in 5 minutes

No backend needed: add your App Key in the app and start calling. A server is optional, for production hardening.

  1. Get your App Key. In the console, open Projects → Quick mode and add your app's website address, package name or bundle ID. Your App Key is shown there.
  2. Install the package.
    terminal
    # the chat package from your console (SDK downloads or a Support ticket)
    # app/build.gradle.kts: implementation("com.titliapp.chat:titli-chat-ui:0.1.0")
  3. Init with the App Key, then start or join a conversation. That is all: no server, no tokens.
    Chat.kt
    val chat = TitliChat.init(applicationContext, appKey = "tak_…", userId = "user-42")
    chat.connect() // no token: the SDK fetches and refreshes it

The App Key is publishable, not a secret: it can only reach the app-facing routes, it is bound to your package name, bundle ID or website, and spend and usage caps fence it. The binding is a deterrent, not a lock (a determined attacker can copy an app's identity), so the caps are what limit the damage. For strict control, add server tokens (production hardening below). Quick mode: bindings, caps and error codes · Read the Client API (Quick mode).

That is the whole setup: connect() with no token asks for the chat token with your App Key (POST /v1/chat/client/tokens), refreshes it before it expires and whenever the server asks, and saves the user's own profile (PUT /v1/chat/client/users/{user_id}). See the Client API (Quick mode). A server is optional: it is under production hardening at the end.

The detail for Android: install, connect and show the UI, then push and calls. Android 7.0 or later (minSdk 24), Java 17.

1. Install (after access is granted)

The artifacts are not on Maven Central or JitPack. Download titli-chat-android-0.1.0.zip from the console (SDK downloads) and unzip it next to your project, for example into vendor/titli-chat-android-0.1.0. Its maven/ folder is a ready Maven repository with the three chat artifacts and the Titli Video SDK they build against.

build.gradle.kts
// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("vendor/titli-chat-android-0.1.0/maven") }  // the folder from the downloaded archive
        maven("https://jitpack.io")  // only for titli-chat-calls (LiveKit's audioswitch dependency)
    }
}

// app/build.gradle.kts (after access is granted)
dependencies {
    implementation("com.titliapp.chat:titli-chat-ui:0.1.0")      // Compose UI kit, brings the core (titli-chat)
    implementation("com.titliapp.chat:titli-chat-calls:0.1.0")   // optional: audio/video calls from the chat
}

Permissions (INTERNET, ACCESS_NETWORK_STATE, and RECORD_AUDIO for voice notes, asked the first time the user records) come with the SDK's manifests and merge into your app. Nothing to add.

2. Connect and show the UI

ChatActivity.kt
import com.titliapp.chat.TitliChat
import com.titliapp.chat.ui.TitliChatScreen
import com.titliapp.chat.ui.TitliConversationList

class ChatActivity : ComponentActivity() {
    // Quick mode: your App Key and your own user id. No backend needed.
    // Keep one client per signed-in user (for example in your Application class).
    private val chat by lazy { TitliChat.init(applicationContext, appKey = "tak_…", userId = "u_42", userName = "Asha") }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        lifecycleScope.launch { chat.connect() }   // no token: fetched and refreshed with the App Key
        setContent {
            var open by remember { mutableStateOf<String?>(null) }
            val cid = open
            if (cid == null) {
                TitliConversationList(chat, onOpen = { open = it.id })
            } else {
                TitliChatScreen(chat, cid, onBack = { open = null })
            }
        }
    }
}

Start a chat with someone: val conv = chat.openDirect("their_user_id"), then show TitliChatScreen(chat, conv.id).

The screens load history, page on scroll, show typing, ticks and reactions, send images, files and voice notes, and keep sending through bad networks: messages typed offline are queued on the device and sent once, in order, when the connection is back. Light and dark follow the system; pass theme = TitliChatTheme(accent = Color(0xFF0E9F6E)) for your brand colour.

Push notifications (FCM)

Push on a real Android phone is not verified yet. The code below is what the SDK provides; treat it as beta and tell us what you see.

The SDK does not depend on Firebase. Add Firebase Cloud Messaging to your app, upload the FCM service account in the console (Chat → Push), then:

MyMessagingService.kt
class MyMessagingService : FirebaseMessagingService() {
    override fun onNewToken(token: String) { appScope.launch { runCatching { chat.registerPush(token) } } }

    override fun onMessageReceived(message: RemoteMessage) {
        if (TitliChatCalls.showIncomingFromPush(this, message.data, ChatActivity::class.java)) return // a call: rings
        val push = TitliChatPush.parse(message.data) ?: return   // not a Titli Chat push
        showNotification(title = push.title, body = push.body, cid = push.cid)   // your own notification code
    }
}

// once after connect():
chat.registerPush(FirebaseMessaging.getInstance().token.await())

Without titli-chat-calls, drop the first line of onMessageReceived. Call chat.unregisterPush(token) on sign-out. appScope is your own application-level coroutine scope.

A message push carries a notification block besides the data keys, so while your app is in the background Android shows it by itself and onMessageReceived runs only in the foreground. A call push is data-only and always reaches onMessageReceived. In 0.1.0 the call push does not carry the call_id, so a call answered from a push on a closed app cannot join yet; calls ring and connect normally while the app holds a connection.

Calls (with the Titli Video SDK)

titli-chat-calls connects the chat's call invitations to the Titli Video SDK for Android: a call button in the chat header, a ringing notification and banner for incoming calls, and the call screen. Because the chat was made with your App Key, leave out credentials and createCall: the calls are created and joined through the Video SDK's Quick mode (TitliVideo.startCall and joinCall underneath), paid by the caller. No backend.

Calls.kt
// Quick mode: no credentials or createCall needed
val calls = TitliChatCalls(applicationContext, chat, activity = ChatActivity::class.java).also { it.start() }

// ChatActivity
override fun onNewIntent(intent: Intent) { super.onNewIntent(intent); calls.handleIntent(intent) }   // also call it in onCreate

setContent {
    TitliChatCallHost(calls) {                       // shows the incoming-call banner and the call screen over your UI
        TitliChatScreen(chat, cid, headerActions = { conv ->
            TitliChatCallButton(calls, conv, video = false)
            TitliChatCallButton(calls, conv, video = true)
        })
    }
}

Use android:launchMode="singleTask" on that activity. For a full-screen ring over the lock screen add <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" /> (Google Play allows it for calling apps); without it the SDK posts a heads-up notification with Answer and Decline.

Production hardening (optional): server tokens

You do not need a server to start: Quick mode works with the App Key alone. Add a server when you want strict control over every call (who joins which call, for how long, in which role): keep the project key on your server and mint a short-lived join token per person there. The app uses the same SDK and hands it a token instead of the App Key. Both ways can run side by side.

Chat token from your server

Your server keeps the API key and mints a short-lived token for the signed-in user (any language works; Node shown). user_id is your own user id: 1 to 128 characters from A-Z a-z 0-9 _ . : @ -.

server.js
// Your server (Node 20+), optional: production hardening. The API key stays here, never in the app.
app.post('/titli/chat-token', async (req, res) => {
  const r = await fetch('https://api-videosdk.titliapp.com/v1/chat/tokens', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: 'Basic ' + Buffer.from(process.env.TITLI_KEY_ID + ':' + process.env.TITLI_KEY_SECRET).toString('base64'),
    },
    // req.user is YOUR signed-in user (from your own session), never taken from the request body
    body: JSON.stringify({ user_id: req.user.id, name: req.user.name, ttl_seconds: 3600 }),
  });
  if (!r.ok) return res.status(502).json({ error: await r.text() });
  res.json({ token: (await r.json()).token });
});

In the app (OkHttp shown; any HTTP client works):

ChatToken.kt
suspend fun fetchChatToken(): String = withContext(Dispatchers.IO) {
    val req = Request.Builder().url("https://your-server.example/titli/chat-token").post(ByteArray(0).toRequestBody()).build()
    OkHttpClient().newCall(req).execute().use { res -> JSONObject(res.body!!.string()).getString("token") }
}
ChatActivity.kt
// Same SDK, Secure mode: the token comes from your server
private val chat by lazy { TitliChat.create(applicationContext, "https://api-videosdk.titliapp.com") }
lifecycleScope.launch { chat.connect(fetchChatToken(), tokenProvider = ::fetchChatToken) }

Calls with server tokens

Pass your own credentials and createCall; your server creates the call and the tokens exactly as in the video quickstart (production hardening there):

Calls.kt
val calls = TitliChatCalls(
    applicationContext, chat, activity = ChatActivity::class.java,
    credentials = { callId -> myServer.callToken(callId) },        // your server: POST /v1/calls/{call_id}/tokens -> TitliCallCredentials(url, token)
    createCall = { isVideo, _ -> myServer.createCall(isVideo) },   // your server: POST /v1/calls -> call_id
).also { it.start() }

Known gaps in 0.1.0

  • No public package mirror: access is requested in the console (see the note at the top).
  • Push on real devices is not verified yet. Testing so far was on emulators and on macOS.
  • Calls from a push: the server's call push has no call_id and iOS gets a normal alert, not a VoIP push. A closed app shows the ring or notification but cannot join from it; ringing and joining work while the app is connected.
  • Attachments that were still uploading are not kept across an app restart (text and uploaded attachments are).
  • Group chats show "sent" ticks only; per-member receipts are events in the core, not drawn by the UI kit.
  • No search screen and no mentions picker in the UI kit (the core APIs exist).

Next

  • The README inside the package you receive covers the core API: events, groups, live rooms, receipts, the offline queue and theming.
  • A sample app ships in the package (sample).
  • Chat API reference: REST endpoints, WebSocket operations, events, errors and webhooks.
  • Chat quickstart for the web, the React UI kit and Flutter, which are available today without a request.
Start free