For AI agents: Find a documentation index at https://talkjs.com/llms.txt (full content at https://talkjs.com/llms-full.txt). Get a markdown version of any page by appending .md to its URL path.
Skip to content
Swift logo

Swift

iOS Chat SDK

TalkJS’s Swift Data API is a native, headless SDK for adding real-time chat to iOS apps. You build the UI in SwiftUI or UIKit, while TalkJS handles real-time messaging, presence, and push notifications through APNs.

Classtime
Decathlon
Riot Games
Hyundai

Everything you need for real-time iOS messaging

The TalkJS Swift Data API gives your iOS app the core messaging features of a chat SDK, with real-time updates delivered to your own Swift views.

Messages & replies

Send text messages and reply to a specific message, so threads of conversation stay clear in busy chats.

Conversation list

Subscribe to the user’s most recently active conversations to build an inbox that updates as new messages arrive.

What was the name again of the blog you mentioned yesterday?
2m ago
Typing indicators

Show when someone’s typing in a conversation. Indicators clear automatically after 10 seconds or when a message is sent.

Foodies

User 1User 2User 3User 4User 5

Channel5 members

Online presence

Subscribe to a user’s online status to show who’s available before your users start a conversation.

Coffee at 3pm?
1m ago
Profile picOleg
Sure thing! How about that new place in Market Street?
just now
Read state

Mark a conversation as read when the user opens it, or as unread so they can come back to it later.

import { Chatbox } from '@talkjs/react-components';

import "@talkjs/react-components/default.css";
import { TalkSession } from "@talkjs/core";
import { useEffect } from "react";

function Chat() { const appId = '<APP_ID>'; const userId = 'frank'; const otherUserId = 'nina'; const conversationId = 'new_conversation'; const session = getTalkSession({ appId, userId });

useEffect(() => { session.currentUser.createIfNotExists({ name: 'Frank' }); session.user(otherUserId).createIfNotExists({ name: 'Nina' });

    const conversation = session.conversation(conversationId);
    conversation.createIfNotExists();
    conversation.participant(otherUserId).createIfNotExists();

}, [session, conversationId, otherUserId]);

return ( <div style={{ width: '400px', height: '800px' }}> <Chatbox
        appId={appId}
        userId={userId}
        conversationId={conversationId}
    /> </div> ); }
Avatar
Hey, I'm trying to lift state up from a child component, but I'm getting undefined errors. Any ideas?
8m ago
Avatar
Are you passing the state and the setState function correctly as props?
10m ago
Avatar
I think so, yes.
7m ago
OK hand emoji
Thinking emoji
Avatar
Maybe you're not binding the handler in the constructor. That might be the issue.
2m ago
Avatar
Say something...
Avatar
Avatar
4
AI integration strategy
Andrea, Robert, Nikki, Filip
Avatar
Andrea
10m ago
Hey team, how do you think we can integrate AI into our project?
Avatar
Robert
8m ago
Maybe we can use AI for data analysis. It can help us find trends faster.
Avatar
Nikki
7m ago
Good idea @Robert. What about automating customer support? AI agents could handle common queries.
Avatar
Filip
2m ago
00:15
1x
Say something...
Emoji reactions

Let users react to messages with Unicode or custom emoji, with up to 50 different reactions per message.

https://youtu.be/SFKc9rDrKDM?si=n4WcD_kr52jOFqOPVideo still
4m ago
User avatar
Files, media & location

Upload and send images, files, videos, audio, and voice recordings, or share a location pin in a conversation.

Explore Travel

now

Flight update

Check in online for your Singapore flight tomorrow. Upgrade to priority boarding.

Push notifications via APNs

Register a device’s APNs token on the user to notify them of new messages when your app isn’t in the foreground.

Get started in three steps

Install the Swift Data API, connect as a user, and send your first message in three steps.

01

Add the Swift package

In Xcode, choose File > Add Package Dependencies..., enter https://github.com/talkjs/talkjs-core-swift, and add the talkjs-core-swift library to your app target. If you use a Package.swift file, add the package as a dependency instead:

dependencies: [
  .package(url: "https://github.com/talkjs/talkjs-core-swift", from: "<latest_version>"),
]

02

Create a session

Import the talkjs_core_swift module and create a session for the current user with your TalkJS app ID, found on the Settings page of your TalkJS dashboard:

import talkjs_core_swift

let session = getTalkSession(
  appId: "<APP_ID>", // Replace with your own app ID
  userId: "<USER_ID>" // Replace with a user ID
)

03

Subscribe to messages and send one

Get a reference to a conversation, subscribe to its messages, and send a message:

let conversation = session.conversation(id: "<CONVERSATION_ID>")

// Called with the latest messages whenever they change
let subscription = conversation.subscribeMessages { messages, loadedAll in
  print(messages?.map { $0.plaintext } ?? [])
}

Task {
  try await conversation.createIfNotExists()
  try await conversation.send(text: "Hello")
}

You’re now ready to build your inbox and chat views on top of real-time conversation data.

Read the full Swift Data API docs

Bring your own UI, we handle the real-time data

The TalkJS Swift Data API is a headless messaging layer for iOS apps. It connects to TalkJS as a specific user and exposes Swift functions for creating conversations, sending messages, and subscribing to real-time updates. You render that data with SwiftUI, UIKit, or a mix of both, with no TalkJS-provided views in the render path.

Each subscription calls your code with a fresh snapshot whenever its data changes, so your views always show the current messages, typing status, and presence. The same talkjs-core-swift package also runs in macOS 11+ apps.

The Swift Data API shares the same core as the TalkJS Kotlin Data API, so the method names match on Android. If you ship native apps for both platforms, your iOS and Android teams work with the same concepts and calls.

Connect AI agents via REST and webhooks

Power AI agents and LLM-backed conversations by pairing your iOS chat with the TalkJS REST API and webhooks. You can trigger a response, route to a bot, or hand off to a human agent, all from your own backend. TalkJS doesn’t bundle a specific AI or bot framework, so you stay in control of the model and logic you use.

A typical pattern: a webhook fires when a user sends a message, your backend calls an LLM, and the REST API sends the response back into the conversation. The Swift Data API connects as a single user, so server-side work like this goes through the REST API. Your iOS app needs no special handling: it receives the AI’s reply as a normal message.

Works with your stack

In addition to the native Swift Data API for iOS, TalkJS supports native Android, cross-platform mobile, web, and server-side integrations.

Mobile

Pair your iOS app with a native Android app, or target both platforms from a single codebase.

Web

Add chat to the web version of your app with pre-built UI components for your framework.

Server-side

Connect to chat data from your backend to manage users, conversations, and messages, or to power AI agents and integrations.

Retreat Guru logo
We were able to offload all messaging to TalkJS — hugely simplifying our development of an otherwise complex stack.
Deryk Wenaus
CTO, Retreat Guru

How TalkJS compares for iOS

See how the TalkJS Swift Data API compares with other iOS chat SDKs on UI options, requirements, installation, and pricing.

Native iOS UI kit
TalkJS
No (headless)
Sendbird
UIKit and SwiftUI
Stream
UIKit and SwiftUI
CometChat
SwiftUI UI Kit
Headless client SDK
TalkJS
Swift Data API
Sendbird
Chat SDK
Stream
Low-level client (StreamChat)
CometChat
CometChat SDK
Minimum iOS version
TalkJS
iOS 15
Sendbird
iOS 13
Stream
iOS 13 (SwiftUI kit: iOS 14)
CometChat
iOS 11 (SDK), iOS 13 (UI Kit)
Installation
TalkJS
Swift Package Manager
Sendbird
Swift Package Manager, CocoaPods, Carthage
Stream
Swift Package Manager
CometChat
Swift Package Manager, CocoaPods
Push notifications via APNs
TalkJS
Yes
Sendbird
Yes
Stream
Yes (APNs or Firebase)
CometChat
Yes
Free tier
TalkJS
Development mode, all features
Sendbird
Free trial: up to 1,000 MAU, 20 concurrent connections
Stream
Build plan: 1,000 MAU free
CometChat
Build plan: up to 100 users
Price at 10,000 MAU (USD per month, billed annually)
TalkJS
Basic: $239
Sendbird
Starter: $429
Stream
Start: $399
CometChat
Basic: $299

FAQs

The TalkJS iOS chat SDK is the Swift Data API, a native, headless SDK distributed as the talkjs-core-swift Swift package. It connects to TalkJS as one user and lets your app read, subscribe to, and update conversations, messages, and users in real time, while you build the chat UI in SwiftUI or UIKit. It needs Swift 6.3+ and runs on iOS 15+ and macOS 11+. Install it with Swift Package Manager.

It depends on whether you want pre-built chat screens or full control over your UI. Stream, Sendbird, and CometChat ship pre-built UIKit or SwiftUI screens. The TalkJS Swift Data API is headless: you build the chat UI in SwiftUI or UIKit, push notifications through APNs are built in, and it shares the same core as the Kotlin Data API, so your Android app can use the same method names. See how TalkJS compares on UI options, requirements, and pricing.

It’s headless. TalkJS handles real-time messaging, delivery, and state, while you build and own the chat UI in Swift. If you want pre-built mobile chat UI instead, use the TalkJS React Native or Flutter UI components, which run on both iOS and Android.

Yes. The Swift Data API has no UI of its own, so it works with SwiftUI, UIKit, or a mix of both. Subscriptions such as subscribeMessages call your code with a fresh snapshot whenever the data changes, and you render that snapshot in whichever views your app uses.

Yes, through Apple Push Notification service (APNs). Add your .p8 token signing key, Key ID, Team ID, and bundle ID on the Settings page of your TalkJS dashboard, and enable the Push Notifications and Remote notifications capabilities in Xcode. Then add each device’s APNs token to the user’s push tokens with an apns: prefix. See Configure APNs for the full steps.

Yes. The same talkjs-core-swift package runs in macOS 11+ apps as well as iOS 15+ apps, with Swift 6.3+.

It depends on whether you build separate native apps or one shared codebase. For native apps, pair the Swift Data API on iOS with the Kotlin Data API on Android. They share the same core, so the method names match across both apps. For a single codebase, use React Native, with TalkJS’s pre-built UI components or the JavaScript Data API, or use the Flutter UI components, which run on both iOS and Android.

TalkJS is free in development mode with full feature access. You only need a paid plan once you go live with real users. See Pricing for details.