ably/ably-chat-swift
Ably Chat SDK for Swift to build chat experiences at scale
Getting started
Everything you need to get started with Ably:
- Getting started with Ably Chat using Swift.
- Ably Chat SDK and usage docs in Swift.
- Learn about Ably Chat.
- API documentation.
- Chat Example App.
- Play with the livestream chat demo.
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.
This SDK supports the following platforms:
| Platform | Support | | -------- | ------- | | iOS | >= 14.0 | | macOS | >= 11.0 | | tvOS | >= 14.0 |
[!NOTE] Xcode 26.0 or later is required.
Installation
The SDK is distributed as a Swift Package and can be installed using Xcode or by adding it as a dependency in your package's Package.swift.
Using Xcode
To install the ably-chat-swift package in your Xcode Project:
- Open your Xcode project and navigate to File → Add Package Dependencies...
- Paste
https://github.com/ably/ably-chat-swiftin the search box - Select the version you want to use
- Select the Ably Chat SDK for your target
Using Swift Package Manager
To install the ably-chat-swift package in another Swift Package, add the following to your Package.swift:
.package(url: "https://github.com/ably/ably-chat-swift", from: "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:
import Ably
import AblyChat
// Initialize Ably Realtime client
let realtimeOptions = ARTClientOptions()
realtimeOptions.key = "<your-ably-api-key>"
realtimeOptions.clientId = "your-client-id"
let realtime = ARTRealtime(options: realtimeOptions)
// Create a chat client
let chatClient = ChatClient(realtime: realtime, clientOptions: ChatClientOptions())
// Get a chat room
let room = try await chatClient.rooms.get(named: "my-room", options: RoomOptions())
// Monitor room status
room.onStatusChange { statusChange in
switch statusChange.current {
case .attached:
print("Room is attached")
case .detached:
print("Room is detached")
case .failed(let error):
print("Room failed: \(error)")
default:
print("Room status: \(statusChange.current)")
}
}
// Attach to the room
try await room.attach()
// Subscribe to messages
let subscription = room.messages.subscribe { event in
print("Received message: \(event.message.text)")
}
// Send a message
try await room.messages.send(withParams: SendMessageParams(text: "Hello, World!"))Releases
The CHANGELOG.md contains details of the latest releases for this SDK. You can also view all Ably releases on changelog.ably.com.
Contribute
Read the CONTRIBUTING.md guidelines to contribute to Ably or share feedback or request a new feature.
Support, feedback and troubleshooting
For help or technical support, visit Ably's support page. You can also view the community reported Github issues or raise one yourself.
Package Metadata
Repository: ably/ably-chat-swift
Stars: 2
Forks: 7
Open issues: 56
Default branch: main
Primary language: swift
License: Apache-2.0
README: README.md