iOS chat SDK quickstart Beta

Native Swift chat for iOS with a SwiftUI kit: conversation list, chat screen, voice messages, push registration and call invites that open the Titli Video SDK. Beta 0.1.0, on request.

Beta 0.1.0, on request. The iOS 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)
    # Xcode → Add Package Dependencies… → Add Local… → TitliChat
  3. Init with the App Key, then start or join a conversation. That is all: no server, no tokens.
    Chat.swift
    let chat = TitliChat(appKey: "tak_…", userId: "user-42")
    try await 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 iOS: install, connect and show the UI, then push and calls. iOS 15+, Xcode 15+.

1. Install (after access is granted)

Download titli-chat-ios-0.1.0.zip from the console (SDK downloads) and unzip it next to your app, for example into Vendor/titli-chat-ios-0.1.0. It holds two Swift packages side by side: chat-ios/ (this SDK) and ios/ (the Titli Video SDK that TitliChatCalls builds against). There is no public URL.

Swift Package Manager: Xcode → File → Add Package Dependencies → Add Local, pick the archive's chat-ios folder, then add the TitliChat and TitliChatUI products to your app target (and TitliChatCalls if you want calls inside chat).

Package.swift
// Package.swift alternative (after access is granted): the folder from the downloaded archive
.package(path: "Vendor/titli-chat-ios-0.1.0/chat-ios")

CocoaPods (after access is granted):

Podfile
platform :ios, '15.0'
target 'YourApp' do
  use_frameworks!
  chat = 'Vendor/titli-chat-ios-0.1.0/chat-ios'   # the folder from the downloaded archive
  pod 'TitliChat', :path => chat
  pod 'TitliChatUI', :path => chat
end

Add to Info.plist (voice messages need the microphone; the background mode is for pushes):

Info.plist
<key>NSMicrophoneUsageDescription</key>
<string>We use the microphone to record voice messages.</string>
<key>UIBackgroundModes</key>
<array><string>remote-notification</string></array>

2. Connect and show the UI

ChatTab.swift
import SwiftUI
import TitliChat
import TitliChatUI

struct ChatTab: View {
    // Quick mode: your App Key and your own user id. No backend needed.
    @StateObject private var chat = TitliChat(appKey: "tak_…", userId: "u_42", userName: "Asha")
    @State private var open: String?   // the conversation on screen

    var body: some View {
        Group {
            if let cid = open {
                TitliChatScreen(chat: chat, cid: cid, onBack: { open = nil })
            } else {
                TitliConversationList(chat: chat) { open = $0.id }
            }
        }
        .titliChatTheme(TitliChatTheme(accent: Color(red: 0.43, green: 0.29, blue: 1.0)))
        // No token: the SDK fetches the chat token with your App Key and refreshes it.
        .task { try? await chat.connect() }
    }
}

To start a chat with someone: open = try await chat.openDirect(userId: "user_2002").id.

You get the conversation list with unread badges and presence, and a chat screen with text, photos, files, voice messages, reactions, typing, sent, delivered and read ticks, reply, edit, unsend and history paging. Messages sent while offline are kept on the device and sent once, in order, when the connection is back.

Push (APNs)

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

Upload your APNs key in the console (Chat → Push), add the Push Notifications capability, then register the device:

AppDelegate.swift
func application(_ app: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken token: Data) {
    Task { try? await chat.registerPush(apnsToken: token) }   // after connect
}

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
    guard let push = TitliChatPush.parse(response.notification.request.content.userInfo) else { return } // not a chat push
    if push.kind == .message, let cid = push.cid { open = cid }
}

A push is sent only when the user has no open connection. Call chat.unregisterPush(apnsToken:) on sign-out.

Calls

Add the TitliChatCalls product (it brings the Titli Video SDK for iOS) and the audio and voip background modes plus NSCameraUsageDescription. Chat rings the other person; the Video SDK carries the call. Because the chat was made with your App Key, the bridge creates and joins the call through the Video SDK's Quick mode (TitliVideo.startCall and joinCall underneath): no backend.

Calls.swift
import TitliChatCalls

// Once, next to your TitliChat object (Quick mode: no closures needed).
let calls = TitliChatCallBridge(chat: chat)

// Root view: incoming-call UI (CallKit on iOS, in-app banner elsewhere) and the call screen.
ChatTab().titliChatCalls(calls)

// Chat header: voice and video buttons.
TitliChatScreen(chat: chat, cid: cid, onBack: { open = nil }) {
    TitliChatCallHeaderButtons(bridge: calls, conversation: chat.conversations[cid])
}

Calls while the app is closed. In 0.1.0 Titli Chat sends a call invite to an offline user as a normal APNs alert (kind=call_invite). It does not send VoIP (PushKit) pushes, and that alert does not carry the call_id, so a closed app shows a notification instead of ringing through CallKit. If you need CallKit ringing on a closed app today, send your own VoIP push from your server with the keys titli_chat, kind=call_invite, invitation_id, sender, title, call_id and call_type, and hand it to the bridge inside the PushKit callback: calls.handlePush(payload.dictionaryPayload, completion: completion). CallKit and PushKit ringing need a run on a real device, which has not been done yet.

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:

ChatToken.swift
func fetchChatToken() async throws -> String {
    var req = URLRequest(url: URL(string: "https://your-server.example/titli/chat-token")!)
    req.httpMethod = "POST"
    let (data, _) = try await URLSession.shared.data(for: req)
    return try JSONDecoder().decode([String: String].self, from: data)["token"]!
}
ChatTab.swift
// Same SDK, Secure mode: the token comes from your server
@StateObject private var chat = TitliChat(apiUrl: "https://api-videosdk.titliapp.com")
// tokenProvider is called now and again whenever the token expires.
.task { try? await chat.connect(tokenProvider: { try await fetchChatToken() }) }

Calls with server tokens

Your server creates the call and the tokens exactly as in the video quickstart (production hardening there), and you pass them to the bridge:

Calls.swift
import TitliChatCalls

// Once, next to your TitliChat object.
let calls = TitliChatCallBridge(chat: chat) { invite in
    guard let callId = invite.callId else { throw ChatError(code: "invalid_request", message: "invite has no call_id") }
    let t = try await myServer.callToken(callId: callId)             // your server: POST /v1/calls/{call_id}/tokens
    return (t.livekit_url, t.token)
}

// Root view: incoming-call UI (CallKit on iOS, in-app banner elsewhere) and the call screen.
ChatTab().titliChatCalls(calls)

// Chat header: voice and video buttons.
TitliChatScreen(chat: chat, cid: cid, onBack: { open = nil }) {
    TitliChatCallHeaderButtons(bridge: calls, conversation: chat.conversations[cid]) { kind in
        let c = try await myServer.createCall(type: kind.rawValue)   // POST /v1/calls + /v1/calls/{id}/tokens
        return TitliOutgoingCall(callId: c.call_id, url: c.livekit_url, token: c.token)
    }
}

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 full API, theming, strings, live rooms and building your own UI on the core.
  • A sample app ships in the package (Example, swift run TitliChatSample).
  • 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