Manage message updates
Edit messages and receive real-time update events.
Requires Message Persistence
Enable Message Persistence in the Admin Portal.
Edit messages
editText() replaces an existing message's content.
Method signature
This method takes the following parameters:
1message.editText(
2 newText: String
3) async throws -> MessageImpl
Input
| Parameter | Description |
|---|---|
newText *Type: StringDefault: n/a | New/updated text that you want to add in place of the existing message. |
Output
| Parameter | Description |
|---|---|
MessageImpl | An updated message instance with an added edited action type. |
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.
Correct the number of the support ticket you sent to 78398.
1
Get message updates
Receive real-time updates when messages or reactions change with onUpdated(). You can also use message.stream.updates() for an AsyncStream-based approach.
For monitoring multiple messages at once, streamUpdatesOn() remains available.
Deprecation
streamUpdates() is deprecated. Use onUpdated() (closure-based) or message.stream.updates() (AsyncStream-based) instead.
Method signature
-
onUpdated()— closure called when the message changes1message.onUpdated(
2 callback: @escaping (MessageImpl) -> Void
3) -> AutoCloseable -
streamUpdatesOn()(static) — monitors multiple messages1MessageImpl.streamUpdatesOn(
2 messages: [MessageImpl]
3) -> AsyncStream<[MessageImpl]>
Input
| Parameter | Description |
|---|---|
callback (in onUpdated) *Type: (MessageImpl) -> VoidDefault: n/a | Closure called with the updated message whenever it changes (edits, reactions, etc.). |
messages (in streamUpdatesOn) *Type: [MessageImpl]Default: n/a | A collection of MessageImpl objects for which you want to get updates on changed messages or message reactions. |
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.
Get message and message reaction-related updates for the message with the timetoken 16200000000000000 published on the support channel.
- Closure
- AsyncStream
1
1
Watch multiple messages
Get updates on multiple message objects at once.
- Closure
- AsyncStream
1
1