Set Chat Markers
The Chat Markers API gives you control over the creation of Chat Markers. You can use Chat Markers to mark messages as read. It also provides data for the Conversation list API. This functionality works in both channels and direct messages.
To set a conversation's read marker, sign in to the application and use VivoxService.Instance.SetMessageAsReadAsync()
.
A VivoxMessage
input is used by the method to determine which type of conversation it belongs to and the MessageId
of the message to set as read.
This method sets a read checkpoint for the relevant conversation at the MessageId
of the VivoxMessage
provided.
Note: The marker is created even if the URI or message doesn’t exist. In the future, this information will be used to augment the Conversations API.
The following code is an example of how to set a Chat Marker.
DateTime seenAt = DateTime.Now; // Optional timestamp for when the message was seen. Default is DateTime.Now converted to UTC.
var readMessage = await VivoxService.Instance.SetMessageAsReadAsync(message, seenAt);
A VivoxMessage
with its IsRead
property set to true will be returned upon completion.
Since a VivoxMessage
instance canont be created manually, the input for VivoxService.Instance.SetMessageAsReadAsync()
needs to come from one of the events or methods in the SDK that provides a VivoxMessage
to the client.
These are some examples of events and methods that provide VivoxMessage
instances that can be used as input for VivoxService.Instance.SetMessageAsReadAsync()
:
// Events
ChannelMessageReceived;
ChannelMessageEdited;
ChannelMessageDeleted;
DirectedMessageReceived;
DirectedMessageDeleted;
DirectedMessageEdited;
// Methods
GetChannelTextMessageHistoryAsync();
GetDirectTextMessageHistoryAsync();