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

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 GetMessageHistory() 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 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

Last updated on