ChatMessageStore ChatMessageStore ChatMessageStore ChatMessageStore Class

Definition

Provides the methods and properties to read, manage and send messages. An application gets access to the message store using the static ChatMessageManager class.

public : sealed class ChatMessageStore : IChatMessageStore, IChatMessageStore2, IChatMessageStore3public sealed class ChatMessageStore : IChatMessageStore, IChatMessageStore2, IChatMessageStore3Public NotInheritable Class ChatMessageStore Implements IChatMessageStore, IChatMessageStore2, IChatMessageStore3// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Obtain an instance of this class by calling RequestStoreAsync.

Properties

ChangeTracker ChangeTracker ChangeTracker ChangeTracker

Gets a ChatMessageChangeTracker class object for the message store. A message change tracker allows an application to monitor changes to messages in the message store.

public : ChatMessageChangeTracker ChangeTracker { get; }public ChatMessageChangeTracker ChangeTracker { get; }Public ReadOnly Property ChangeTracker As ChatMessageChangeTracker// You can use this property in JavaScript.

Remarks

An application can enable change tracking by accessing this ChatMessageChangeTracker object. The following example shows how to enable message change tracking.

// Enable message change tracking
void SetTrackingOn(ChatMessageStore store)
{
    store.ChangeTracker.Enable();
}

The chat application receives notifications of message changes in its message change event handler which is registered to the MessageChanged event.

Methods

DeleteMessageAsync(String) DeleteMessageAsync(String) DeleteMessageAsync(String) DeleteMessageAsync(String)

Deletes a message from the chat message store.

public : IAsyncAction DeleteMessageAsync(PlatForm::String localMessageId)public IAsyncAction DeleteMessageAsync(String localMessageId)Public Function DeleteMessageAsync(localMessageId As String) As IAsyncAction// You can use this method in JavaScript.
Parameters
localMessageId
PlatForm::String String String String

The local ID of the message to be deleted.

Returns
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
blockedChatMessages

DownloadMessageAsync(String) DownloadMessageAsync(String) DownloadMessageAsync(String) DownloadMessageAsync(String)

Downloads a message specified by the identifier to the message store.

public : IAsyncAction DownloadMessageAsync(PlatForm::String localChatMessageId)public IAsyncAction DownloadMessageAsync(String localChatMessageId)Public Function DownloadMessageAsync(localChatMessageId As String) As IAsyncAction// You can use this method in JavaScript.
Parameters
localChatMessageId
PlatForm::String String String String

The local ID of the message to be downloaded.

Returns

Remarks

The message contents including its attachments are downloaded. An application will call this method when the message status is ChatMessageStatus.ReceiveDownloadNeeded.

ForwardMessageAsync(String, IIterable) ForwardMessageAsync(String, IIterable) ForwardMessageAsync(String, IIterable) ForwardMessageAsync(String, IIterable)

Asynchronously forwards the specified message to new recipients.

public : IAsyncOperation<ChatMessage> ForwardMessageAsync(PlatForm::String localChatMessageId, IIterable<PlatForm::String> addresses)public IAsyncOperation<ChatMessage> ForwardMessageAsync(String localChatMessageId, IEnumerable<String> addresses)Public Function ForwardMessageAsync(localChatMessageId As String, addresses As IEnumerable<String>) As IAsyncOperation( Of ChatMessage )// You can use this method in JavaScript.
Parameters
localChatMessageId
PlatForm::String String String String

The ID of the message to forward.

addresses
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The addresses of the new recipients of the forwarded message.

Returns

GetConversationAsync(String) GetConversationAsync(String) GetConversationAsync(String) GetConversationAsync(String)

Asynchronously gets a ChatConversation by ID.

public : IAsyncOperation<ChatConversation> GetConversationAsync(PlatForm::String conversationId)public IAsyncOperation<ChatConversation> GetConversationAsync(String conversationId)Public Function GetConversationAsync(conversationId As String) As IAsyncOperation( Of ChatConversation )// You can use this method in JavaScript.
Parameters
conversationId
PlatForm::String String String String

The ID of the conversation to retrieve.

Returns
See Also

GetConversationAsync(String, IIterable) GetConversationAsync(String, IIterable) GetConversationAsync(String, IIterable) GetConversationAsync(String, IIterable)

Asynchronously gets a ChatConversation by ID using the specified transports.

public : IAsyncOperation<ChatConversation> GetConversationAsync(PlatForm::String conversationId, IIterable<PlatForm::String> transportIds)public IAsyncOperation<ChatConversation> GetConversationAsync(String conversationId, IEnumerable<String> transportIds)Public Function GetConversationAsync(conversationId As String, transportIds As IEnumerable<String>) As IAsyncOperation( Of ChatConversation )// You can use this method in JavaScript.
Parameters
conversationId
PlatForm::String String String String

The ID of the conversation to retrieve.

transportIds
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The IDs of the transports to use to retrieve the ChatConversation.

Returns
See Also

GetConversationFromThreadingInfoAsync(ChatConversationThreadingInfo) GetConversationFromThreadingInfoAsync(ChatConversationThreadingInfo) GetConversationFromThreadingInfoAsync(ChatConversationThreadingInfo) GetConversationFromThreadingInfoAsync(ChatConversationThreadingInfo)

Asynchronously gets a conversation based on a threading info object.

public : IAsyncOperation<ChatConversation> GetConversationFromThreadingInfoAsync(ChatConversationThreadingInfo threadingInfo)public IAsyncOperation<ChatConversation> GetConversationFromThreadingInfoAsync(ChatConversationThreadingInfo threadingInfo)Public Function GetConversationFromThreadingInfoAsync(threadingInfo As ChatConversationThreadingInfo) As IAsyncOperation( Of ChatConversation )// You can use this method in JavaScript.
Parameters
Returns

GetConversationReader() GetConversationReader() GetConversationReader() GetConversationReader()

Gets a new or existing ChatConversationReader for the message store.

public : ChatConversationReader GetConversationReader()public ChatConversationReader GetConversationReader()Public Function GetConversationReader() As ChatConversationReader// You can use this method in JavaScript.
Returns
See Also

GetConversationReader(IIterable) GetConversationReader(IIterable) GetConversationReader(IIterable) GetConversationReader(IIterable)

Gets a new or existing ChatConversationReader for the message store using the specified transports.

public : ChatConversationReader GetConversationReader(IIterable<PlatForm::String> transportIds)public ChatConversationReader GetConversationReader(IEnumerable<String> transportIds)Public Function GetConversationReader(transportIds As IEnumerable<String>) As ChatConversationReader// You can use this method in JavaScript.
Parameters
transportIds
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The IDs for the transports to use to retrieve the ChatConversationReader.

Returns
See Also

GetMessageAsync(String) GetMessageAsync(String) GetMessageAsync(String) GetMessageAsync(String)

Retrieves a message specified by an identifier from the message store.

public : IAsyncOperation<ChatMessage> GetMessageAsync(PlatForm::String localChatMessageId)public IAsyncOperation<ChatMessage> GetMessageAsync(String localChatMessageId)Public Function GetMessageAsync(localChatMessageId As String) As IAsyncOperation( Of ChatMessage )// You can use this method in JavaScript.
Parameters
localChatMessageId
PlatForm::String String String String

The local ID of the chat message to be retrieved.

Returns

An asynchronous operation that returns a chat message upon successful completion.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
blockedChatMessages

Remarks

The message corresponding to the specified identifier is returned. An application can use this method to display a message or store messages in its own private cache.

GetMessageByRemoteIdAsync(String, String) GetMessageByRemoteIdAsync(String, String) GetMessageByRemoteIdAsync(String, String) GetMessageByRemoteIdAsync(String, String)

Gets a message by its remote ID.

public : IAsyncOperation<ChatMessage> GetMessageByRemoteIdAsync(PlatForm::String transportId, PlatForm::String remoteId)public IAsyncOperation<ChatMessage> GetMessageByRemoteIdAsync(String transportId, String remoteId)Public Function GetMessageByRemoteIdAsync(transportId As String, remoteId As String) As IAsyncOperation( Of ChatMessage )// You can use this method in JavaScript.
Parameters
transportId
PlatForm::String String String String

The TransportId to use to get the ChatMessage.

remoteId
PlatForm::String String String String

The RemoteId of the ChatMessage to retrieve.

Returns
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
blockedChatMessages

GetMessageBySyncIdAsync(String) GetMessageBySyncIdAsync(String) GetMessageBySyncIdAsync(String) GetMessageBySyncIdAsync(String)

Gets a message by the sync ID.

public : IAsyncOperation<ChatMessage> GetMessageBySyncIdAsync(PlatForm::String syncId)public IAsyncOperation<ChatMessage> GetMessageBySyncIdAsync(String syncId)Public Function GetMessageBySyncIdAsync(syncId As String) As IAsyncOperation( Of ChatMessage )// You can use this method in JavaScript.
Parameters
syncId
PlatForm::String String String String

The sync ID of the message.

Returns
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

GetMessageReader() GetMessageReader() GetMessageReader() GetMessageReader()

Gets a ChatMessageReader class object which provides a message collection from the message store.

public : ChatMessageReader GetMessageReader()public ChatMessageReader GetMessageReader()Public Function GetMessageReader() As ChatMessageReader// You can use this method in JavaScript.
Returns

Remarks

The following example uses the message reader to find the first message that has a subject containing a simple search string:

async ChatMessage SearchMessagesBySubject(ChatMesssage store, string searchItem)
{
    ChatMessage foundMessage = null;
    IReadOnlyList<ChatMessage> messageList = await store.GetMessageReader().ReadBatchAsync();
    if (messageList.Count > 0)
    {
        foreach(ChatMessage message in messageList)
        {
            If (message.Subject.Contains(searchItem))
            {
                foundMessage = message;{
                break;
            }
        }
    }
    return foundMessage;
}
See Also

GetMessageReader(TimeSpan) GetMessageReader(TimeSpan) GetMessageReader(TimeSpan) GetMessageReader(TimeSpan)

Gets a ChatMessageReader class object which provides a message collection from the message store. The collection of messages is limited to the time span provided.

public : ChatMessageReader GetMessageReader(TimeSpan recentTimeLimit)public ChatMessageReader GetMessageReader(TimeSpan recentTimeLimit)Public Function GetMessageReader(recentTimeLimit As TimeSpan) As ChatMessageReader// You can use this method in JavaScript.
Parameters
recentTimeLimit
TimeSpan TimeSpan TimeSpan TimeSpan

The time window for the retrieved reader.

Returns
See Also

GetSearchReader(ChatQueryOptions) GetSearchReader(ChatQueryOptions) GetSearchReader(ChatQueryOptions) GetSearchReader(ChatQueryOptions)

Gets a new or existing ChatSearchReader to be used to search for messages.

public : ChatSearchReader GetSearchReader(ChatQueryOptions value)public ChatSearchReader GetSearchReader(ChatQueryOptions value)Public Function GetSearchReader(value As ChatQueryOptions) As ChatSearchReader// You can use this method in JavaScript.
Parameters
value
ChatQueryOptions ChatQueryOptions ChatQueryOptions ChatQueryOptions

The query options that the search reader will use when looking for matching messages.

Returns

GetUnseenCountAsync() GetUnseenCountAsync() GetUnseenCountAsync() GetUnseenCountAsync()

Asynchronously gets the number of unread chat messages.

public : IAsyncOperation<int> GetUnseenCountAsync()public IAsyncOperation<int> GetUnseenCountAsync()Public Function GetUnseenCountAsync() As IAsyncOperation( Of int )// You can use this method in JavaScript.
Returns
See Also

GetUnseenCountAsync(IIterable) GetUnseenCountAsync(IIterable) GetUnseenCountAsync(IIterable) GetUnseenCountAsync(IIterable)

Asynchronously gets the number of unread chat messages using the specified transports.

public : IAsyncOperation<int> GetUnseenCountAsync(IIterable<PlatForm::String> transportIds)public IAsyncOperation<int> GetUnseenCountAsync(IEnumerable<String> transportIds)Public Function GetUnseenCountAsync(transportIds As IEnumerable<String>) As IAsyncOperation( Of int )// You can use this method in JavaScript.
Parameters
transportIds
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The IDs of the chat transports to use to get the unseen messages count.

Returns
See Also

MarkAsSeenAsync() MarkAsSeenAsync() MarkAsSeenAsync() MarkAsSeenAsync()

Asynchronously marks all transport messages as seen.

public : IAsyncAction MarkAsSeenAsync()public IAsyncAction MarkAsSeenAsync()Public Function MarkAsSeenAsync() As IAsyncAction// You can use this method in JavaScript.
Returns

An async action indicating that the operation has finished.

See Also

MarkAsSeenAsync(IIterable) MarkAsSeenAsync(IIterable) MarkAsSeenAsync(IIterable) MarkAsSeenAsync(IIterable)

Asynchronously marks all transport messages as seen.

public : IAsyncAction MarkAsSeenAsync(IIterable<PlatForm::String> transportIds)public IAsyncAction MarkAsSeenAsync(IEnumerable<String> transportIds)Public Function MarkAsSeenAsync(transportIds As IEnumerable<String>) As IAsyncAction// You can use this method in JavaScript.
Parameters
transportIds
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The IDs of the transports for which to mark all messages as seen.

Returns

An async action indicating that the operation has finished.

See Also

MarkMessageReadAsync(String) MarkMessageReadAsync(String) MarkMessageReadAsync(String) MarkMessageReadAsync(String)

Marks a specified message in the store as already read.

public : IAsyncAction MarkMessageReadAsync(PlatForm::String localChatMessageId)public IAsyncAction MarkMessageReadAsync(String localChatMessageId)Public Function MarkMessageReadAsync(localChatMessageId As String) As IAsyncAction// You can use this method in JavaScript.
Parameters
localChatMessageId
PlatForm::String String String String

The local ID of the message to be marked as read.

Returns
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
blockedChatMessages

Remarks

The IsRead property of the ChatMessage class matching the localMessageId parameter is set to "true" when this method completes.

RetrySendMessageAsync(String) RetrySendMessageAsync(String) RetrySendMessageAsync(String) RetrySendMessageAsync(String)

Attempts a retry of sending a specified message from the message store.

public : IAsyncAction RetrySendMessageAsync(PlatForm::String localChatMessageId)public IAsyncAction RetrySendMessageAsync(String localChatMessageId)Public Function RetrySendMessageAsync(localChatMessageId As String) As IAsyncAction// You can use this method in JavaScript.
Parameters
localChatMessageId
PlatForm::String String String String

The local ID of the message to be retried.

Returns

Remarks

The message contents including its attachments are downloaded. An application will call this method it if it chooses to retry sending the message when the message status is ChatMessageStatus.SendFailed.

SaveMessageAsync(ChatMessage) SaveMessageAsync(ChatMessage) SaveMessageAsync(ChatMessage) SaveMessageAsync(ChatMessage)

Asynchronously saves a message to the ChatMessageStore.

public : IAsyncAction SaveMessageAsync(ChatMessage chatMessage)public IAsyncAction SaveMessageAsync(ChatMessage chatMessage)Public Function SaveMessageAsync(chatMessage As ChatMessage) As IAsyncAction// You can use this method in JavaScript.
Parameters
chatMessage
ChatMessage ChatMessage ChatMessage ChatMessage

The message to save.

Returns

An async action indicating that the operation has finished.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
blockedChatMessages

SendMessageAsync(ChatMessage) SendMessageAsync(ChatMessage) SendMessageAsync(ChatMessage) SendMessageAsync(ChatMessage)

Attempts to send a chat message. The message is saved to the message store as part of the send operation.

public : IAsyncAction SendMessageAsync(ChatMessage chatMessage)public IAsyncAction SendMessageAsync(ChatMessage chatMessage)Public Function SendMessageAsync(chatMessage As ChatMessage) As IAsyncAction// You can use this method in JavaScript.
Parameters
chatMessage
ChatMessage ChatMessage ChatMessage ChatMessage

The chat message to be sent.

Returns

Remarks

Once the send is attempted, the message is assigned an identifier and the Id property is set to this value. If the send operation fails, the application can try sending the message again later with RetrySendMessageAsync method using the assigned identifier.

TryCancelDownloadMessageAsync(String) TryCancelDownloadMessageAsync(String) TryCancelDownloadMessageAsync(String) TryCancelDownloadMessageAsync(String)

Asynchronously attempts to cancel downloading the specified message.

public : IAsyncOperation<PlatForm::Boolean> TryCancelDownloadMessageAsync(PlatForm::String localChatMessageId)public IAsyncOperation<bool> TryCancelDownloadMessageAsync(String localChatMessageId)Public Function TryCancelDownloadMessageAsync(localChatMessageId As String) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
Parameters
localChatMessageId
PlatForm::String String String String

The ID of the message to stop downloading.

Returns

An async action indicating that the operation has completed.

TryCancelSendMessageAsync(String) TryCancelSendMessageAsync(String) TryCancelSendMessageAsync(String) TryCancelSendMessageAsync(String)

Asynchronously attempts to cancel sending the specified message.

public : IAsyncOperation<PlatForm::Boolean> TryCancelSendMessageAsync(PlatForm::String localChatMessageId)public IAsyncOperation<bool> TryCancelSendMessageAsync(String localChatMessageId)Public Function TryCancelSendMessageAsync(localChatMessageId As String) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
Parameters
localChatMessageId
PlatForm::String String String String

The ID of the message to stop sending.

Returns

An async action indicating that the operation has completed.

ValidateMessage(ChatMessage) ValidateMessage(ChatMessage) ValidateMessage(ChatMessage) ValidateMessage(ChatMessage)

Checks if a chat message is valid and returns the validation result.

public : ChatMessageValidationResult ValidateMessage(ChatMessage chatMessage)public ChatMessageValidationResult ValidateMessage(ChatMessage chatMessage)Public Function ValidateMessage(chatMessage As ChatMessage) As ChatMessageValidationResult// You can use this method in JavaScript.
Parameters
chatMessage
ChatMessage ChatMessage ChatMessage ChatMessage

The chat message to validate.

Returns

Remarks

Message validation will check the properties of the message for proper format, valid transport selected, attachment count, recipient count, and valid recipients.

Events

MessageChanged MessageChanged MessageChanged MessageChanged

An event that occurs when a message in the message store is changed.

public : event TypedEventHandler MessageChanged<ChatMessageStore,  ChatMessageChangedEventArgs>public event TypedEventHandler MessageChanged<ChatMessageStore,  ChatMessageChangedEventArgs>Public Event MessageChanged<ChatMessageStore,  ChatMessageChangedEventArgs>// You can use this event in JavaScript.
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
blockedChatMessages

Remarks

The following simple example demonstrates how to declare and enable change tracking for message changes.

void ChatMessageStore_MessageChanged(ChatMessageStore store, ChatMessageChangedEventArgs changeArgs)
{
    // Act on the event…
}

void SetStoreProperties(ChatMessageStore store)
{
    store.MessageChanged += ChatMessageStore_MessageChanged;
    store.ChangeTracker.Enable();
}

StoreChanged StoreChanged StoreChanged StoreChanged

Occurs when something in the ChatMessageStore has changed.

public : event TypedEventHandler StoreChanged<ChatMessageStore,  ChatMessageStoreChangedEventArgs>public event TypedEventHandler StoreChanged<ChatMessageStore,  ChatMessageStoreChangedEventArgs>Public Event StoreChanged<ChatMessageStore,  ChatMessageStoreChangedEventArgs>// You can use this event in JavaScript.
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
blockedChatMessages