https://github.com/ably/ably-chat-kotlin
Ably Chat SDK for Android to build chat experiences at scale
https://github.com/ably/ably-chat-kotlin
Last synced: 4 months ago
JSON representation
Ably Chat SDK for Android to build chat experiences at scale
- Host: GitHub
- URL: https://github.com/ably/ably-chat-kotlin
- Owner: ably
- License: apache-2.0
- Created: 2024-08-14T13:14:53.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-25T05:56:37.000Z (about 1 year ago)
- Last Synced: 2025-04-25T06:36:11.007Z (about 1 year ago)
- Language: Kotlin
- Homepage:
- Size: 1.45 MB
- Stars: 1
- Watchers: 11
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://central.sonatype.com/artifact/com.ably.chat/chat-android)
[](https://github.com/ably/ably-chat-kotlin/blob/main/LICENSE)
# Ably Chat SDK
Ably Chat is a set of purpose-built APIs for a host of chat features enabling you to create 1:1, 1:Many, Many:1 and Many:Many chat rooms for
any scale. It is designed to meet a wide range of chat use cases, such as livestreams, in-game communication, customer support, or social
interactions in SaaS products. Built on [Ably's](https://ably.com/) core service, it abstracts complex details to enable efficient chat
architectures.
---
## Getting started
Everything you need to get started with Ably Chat for JVM and Android:
* [Getting started: Chat with Kotlin (Android).](https://ably.com/docs/chat/getting-started/android)
* [Getting started: Chat with Kotlin (JVM).](https://ably.com/docs/chat/getting-started/jvm)
* [SDK and usage docs in Kotlin.](https://ably.com/docs/chat/setup?lang=kotlin)
* [SDK and usage docs in Android using Jetpack Compose.](https://ably.com/docs/chat/setup?lang=jetpack)
* [API documentation.](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/)
* [Chat Example App.](https://github.com/ably/ably-chat-kotlin/tree/main/example)
* Play with the [livestream chat demo.](https://ably-livestream-chat-demo.vercel.app/)
---
## Supported platforms
Ably aims to support a wide range of platforms. If you experience any compatibility issues, open an issue in the repository or contact [Ably support](https://ably.com/support).
This SDK supports the following platforms:
| Platform | Support |
|----------|---------|
| Android | Android 7.0+ (API level 24+) |
| Java | Java 8+ |
> [!NOTE]
> Key functionality such as sending and receiving messages is powered by the [ably-java](https://github.com/ably/ably-java) library.
The `ably-java` library is included as an api dependency within the Chat SDK, so there is no need to manually add it to your project.
---
## Installation
The Ably Chat SDK is available on the Maven Central Repository. To include the dependency in your project, add the following to your `build.gradle` file:
For Groovy:
```groovy
implementation 'com.ably.chat:chat:1.2.0'
```
For Kotlin Script (`build.gradle.kts`):
```kotlin
implementation("com.ably.chat:chat:1.2.0")
```
For Android (`build.gradle.kts`):
```kotlin
implementation("com.ably.chat:chat:1.2.0")
implementation("com.ably.chat:chat-extensions-compose:1.2.0")
```
---
## Usage
The following code connects to Ably's chat service, subscribes to a chat room, and sends a message to that room:
```kotlin
import com.ably.chat.ChatClient
import com.ably.chat.RoomOptions
import com.ably.chat.RoomStatus
import io.ably.lib.realtime.AblyRealtime
import io.ably.lib.types.ClientOptions
// Initialize Ably Realtime client
val realtimeClient = AblyRealtime(
ClientOptions().apply {
key = ""
clientId = "your-client-id"
}
)
// Create a chat client
val chatClient = ChatClient(realtimeClient)
// Get a chat room
val room = chatClient.rooms.get("my-room", RoomOptions())
// Monitor room status
room.onStatusChange { statusChange ->
when (statusChange.current) {
RoomStatus.Attached -> println("Room is attached")
RoomStatus.Detached -> println("Room is detached")
RoomStatus.Failed -> println("Room failed: ${statusChange.error}")
else -> println("Room status: ${statusChange.current}")
}
}
// Attach to the room
room.attach()
// Subscribe to messages
val subscription = room.messages.subscribe { message ->
println("Received message: ${message.text}")
}
// Send a message
room.messages.send(text = "Hello, World!")
```
---
## Releases
The [CHANGELOG.md](./CHANGELOG.md) contains details of the latest releases for this SDK. You can also view all Ably releases on [changelog.ably.com](https://changelog.ably.com).
---
## Contribute
Read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines to contribute to Ably or [Share feedback or request](https://forms.gle/mBw9M53NYuCBLFpMA) a new feature.
---
## Support, Feedback, and Troubleshooting
For help or technical support, visit Ably's [support page](https://ably.com/support). You can also view the [community-reported GitHub issues](https://github.com/ably/ably-chat-kotlin/issues) or raise one yourself.