Manage message updates
Edit messages and receive events whenever someone edits them.
Requires Message Persistence
To manage messages in PubNub storage, you must enable Message Persistence for your app's keyset in the Admin Portal.
Edit messages
Change the content of the existing message to a new one using the editText() method.
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
You can receive updates when specific messages and related message reactions are added, edited, or removed on other clients using the following methods:
streamUpdates()checks message and message reaction-related updates on a singleMessageobject.streamUpdatesOn()checks message and message reaction-related updates on a list ofMessageobjects.
Both methods return an asynchronous stream which produces a new value whenever someone adds, edits or deletes a message, or adds or removes a message reaction to/from the specific message(s).
Underneath, these methods subscribe the current user to a channel and add a message reactions event listener to receive all messageAction events of type added or removed.
Stream update behavior
streamUpdates()returns the entire updatedMessageobject (including all message reactions) each time a change occurs.streamUpdatesOn()returns the complete list of messages you're monitoring each time any change occurs to any of them.
Method signature
These methods take the following parameters:
-
streamUpdates()1message.streamUpdates() -> AsyncStream<MessageImpl> -
streamUpdatesOn()(static)1MessageImpl.streamUpdatesOn(
2 messages: [MessageImpl],
3) -> AsyncStream<[MessageImpl]>
Input
| Parameter | Required in streamUpdates() | Required in streamUpdatesOn() | Description |
|---|---|---|---|
messagesType: [MessageImpl]Default: n/a | No | Yes | A collection of MessageImpl objects for which you want to get updates on changed messages or message reactions. |
Output
An asynchronous stream that produces updates when the underlying message(s) change.
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.
-
streamUpdates()Get message and message reaction-related updates for the message with the timetoken
16200000000000000published on thesupportchannel.- AsyncStream
- Closure
11 -
streamUpdatesOn()Get message and message reaction-related updates for the first page of messages published on the
supportchannel.- AsyncStream
- Closure
11