Dela via


ChatMessageNotificationTriggerDetails Class

Definition

Represents the message notification triggered from a registered background task. A chat app can receive notifications of incoming messages or send events by setting a task trigger and task entry point.

public ref class ChatMessageNotificationTriggerDetails sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ChatMessageNotificationTriggerDetails final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ChatMessageNotificationTriggerDetails
Public NotInheritable Class ChatMessageNotificationTriggerDetails
Inheritance
Object Platform::Object IInspectable ChatMessageNotificationTriggerDetails
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)
App capabilities
chat chatSystem smsSend

Remarks

A chat app must register a background task to process notifications in order to serve as the default handler for incoming messages. In order to register a background task, the Package.appxmanifest file must contain a background task extension. Add the following code snippet into the Application/Extensions element.

<Extension Category="windows.backgroundTasks" Entry-Point="Tasks.ExampleBackgroundTask">
    <BackgroundTasks>
        <Task Type="chatMessageNotification"/>
        <Task Type="systemEvent"/>
    </BackgroundTasks>
</Extension>

The background task's Run method receives a task instance with the notification trigger details. The TriggerDetails property is cast to a ChatMessageNotificationTriggerDetails object. The trigger details for a chat message are obtained as shown in the following example.

public void Run(IBackgroundTaskInstance taskInstance)
{
    BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
    ChatMessageNotificationTriggerDetails triggerDetails =
        (ChatMessageNotificationTriggerDetails) taskInstance.TriggerDetails;

    if (triggerDetails != null)
    {
        SendToast(triggerDetails.ChatMessage);
    }
}

Properties

ChatMessage

Gets the message associated with the notification. This is either an incoming message or an outgoing message with a send status event.

ShouldDisplayToast

Gets a Boolean value indicating if the background task should issue a toast notification for the message.

ShouldUpdateActionCenter

Gets a Boolean value indicating if the Windows Action Center should be updated with the message.

ShouldUpdateBadge

Gets a Boolean value indicating if the background task should update the app’s lock screen count.

ShouldUpdateDetailText

Gets a Boolean value indicating that the background task should update the app's tile count for the message.

Applies to