Typing indicator
Typing indicators show users when someone is composing a message. This feature:
- Increases engagement - Users see activity in group chats
- Sets expectations - Users know when to expect a response in 1:1 conversations
Not available for public chats
Typing indicator is disabled in public chats. If you try implementing this feature in a public channel type, you'll get the Typing indicators are not supported in Public chats error.
Start typing
startTyping() activates the typing indicator on a channel.
The method uses a debounce mechanism: signals are sent at intervals rather than on every keystroke. The default timeout is 5000 ms (5 seconds), with a 1000 ms buffer to prevent rapid re-triggering.
Custom timeout
Set a custom timeout with the typingTimeout parameter during initialization.
Method signature
This method has the following signature:
1channel.startTyping() async throws -> Timetoken?
Input
This method doesn't take any parameters.
Output
| Parameter | Description |
|---|---|
Timetoken? | A Timetoken value indicating the action timestamp, or nil if no signal was sent (e.g., a typing indicator was already active). |
Sample code
Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
Start a typing indicator on the support channel.
1
Stop typing
stopTyping() deactivates a typing indicator on a given channel.
Use this method to disable the typing indicator immediately - for example, when a user deletes a previously drafted message - without waiting for the typingTimeout to end.
Method signature
This method has the following signature:
1channel.stopTyping() async throws -> Timetoken?
Input
This method doesn't take any parameters.
Output
| Parameter | Description |
|---|---|
Timetoken? | A Timetoken value indicating the action timestamp, or nil if no signal was sent (e.g., no typing indicator was active). |
Sample code
Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
Stop a typing indicator on the support channel.
1
Get typing events
onTypingChanged() listens for typing signal events on a channel via a closure. You can also use channel.stream.typingChanges() for an AsyncStream-based approach.
Method signature
1channel.onTypingChanged(
2 callback: @escaping ([String]) -> Void
3) -> AutoCloseable
Input
| Parameter | Description |
|---|---|
callback *Type: ([String]) -> VoidDefault: n/a | Closure called with an array of user IDs currently typing whenever someone starts or stops typing. |
Output
| Parameter | Description |
|---|---|
AutoCloseable | An object you must retain. When released or closed, the listener stops. |
Sample code
Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
- Closure
- AsyncStream
1
1