AppNotificationBuilder.SetGroup(String) Method

Definition

Sets the group identifier for an app notification.

public:
 virtual AppNotificationBuilder ^ SetGroup(Platform::String ^ group) = SetGroup;
AppNotificationBuilder SetGroup(winrt::hstring const& group);
public AppNotificationBuilder SetGroup(string group);
function setGroup(group)
Public Function SetGroup (group As String) As AppNotificationBuilder

Parameters

group
String

Platform::String

winrt::hstring

A string identifying the group to which the app notification belongs.

Returns

Returns the AppNotificationBuilder instance so that additional method calls can be chained.

Examples

The following example demonstrates setting the group for an app notification.

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .SetGroup("Notification group")
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

The resulting XML payload:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
</toast>

An example of removing all of the notifications from Notification Center by group.

await AppNotificationManager.Default.RemoveByGroupAsync("Notification group");

Remarks

You can use the group identifier to remove all app notifications in a group from the Notification Center by calling AppNotificationManager.RemoveByGroupAsync.

For guidance on using the AppNotificationBuilder APIs to create the UI for app notifications, see App notification content.

For reference information about the XML schema for app notifications, see App notification content schema.

Applies to