On this page

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​

Method signature​

This method takes the following parameters:

1channel.GetMessage(
2 string timeToken
3)

Input​

* required
ParameterDescription
timeToken *
Type: string
Default:
n/a
Timetoken of the message you want to retrieve from Message Persistence.

Output​

Returns an awaitable Task<ChatOperationResult<Message>> with the Message object if found, otherwise the Error property on the result will be true.

Sample code​

Get the message with the 16200000000000001 timetoken.

1

Get historical details​

With Message Persistence enabled, PubNub stores all historical message data, metadata, and reactions.

Fetch historical message details with GetMessageHistory(). By default, all message reactions and metadata are included in the response.

Get message content​

You can access the MessageText property of the Message object to receive its text content.

Method signature​

This is how you can access the property:

1message.MessageText: string

Properties​

PropertyDescription
MessageText
Type: string
Text content of the returned message.

Sample code​

Get the content of the message with the 16200000000000000 timetoken.

1

Check deletion status​

You can access the IsDeleted property of the Message object to check if it's deleted.

Method signature​

This is how you can access the property:

1message.IsDeleted: bool

Properties​

PropertyDescription
IsDeleted
Type: bool
Info on whether the message has the IsDeleted flag set to true or not.

Sample code​

Get the status of the message with the 16200000000000000 timetoken.

1