Get message details
Get message details, retrieve content, and check if the message was deleted.
Get message details
getMessage() fetches the Message object from Message Persistence based on the message timetoken.
Method signature
This method takes the following parameters:
1channel.getMessage(
2 timetoken: Timetoken
3) async throws -> MessageImpl?
Input
| Parameter | Description |
|---|---|
timetoken *Type: TimetokenDefault: n/a | Timetoken of the message you want to retrieve from Message Persistence. |
Output
| Parameter | Description |
|---|---|
MessageImpl | Returned Message object. |
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 the message with the 16200000000000001 timetoken.
1
Get historical details
If you have Message Persistence enabled on your keyset, PubNub stores all historical info about messages, their metadata, and reactions.
If you want to fetch historical details of a given message, use the getHistory() method. By default, when you fetch historical messages, PubNub returns all message reactions and metadata attached to the retrieved messages.
Get message content
You can access the text property of the Message object to receive its text content.
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 the content of the message with the 16200000000000000 timetoken.
1
Check deletion status
You can access the deleted property of the Message object to check if it was deleted.
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 the status of the message with the 16200000000000000 timetoken.
1