Skip to content

Commit 2ed5405

Browse files
drewbatgitCopilot
andcommitted
Rewrite toast-collections and toast-headers, add API links
- toast-collections: full rewrite as notification-collections, validated code, remove schedule/push subsections, add API links to all section intros - toast-headers: rewrite as app notification headers, remove UWP tab, fix broken legacy links, keep SetHeader XML note - scheduled-notification: add API links to section intros - Add namespace note to scheduled-notification and collections articles Co-authored-by: Copilot <[email protected]>
1 parent 77438c7 commit 2ed5405

7 files changed

Lines changed: 201 additions & 357 deletions

File tree

.openpublishing.redirection.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9540,6 +9540,11 @@
95409540
"redirect_url": "scheduled-notification",
95419541
"redirect_document_id": true
95429542
},
9543+
{
9544+
"source_path": "hub/apps/develop/notifications/app-notifications/toast-collections.md",
9545+
"redirect_url": "notification-collections",
9546+
"redirect_document_id": true
9547+
},
95439548
{
95449549
"redirect_document_id": false
95459550
},
@@ -9600,7 +9605,7 @@
96009605
},
96019606
{
96029607
"source_path": "hub/apps/design/shell/tiles-and-notifications/toast-collections.md",
9603-
"redirect_url": "../../../develop/notifications/app-notifications/toast-collections",
9608+
"redirect_url": "../../../develop/notifications/app-notifications/notification-collections",
96049609
"redirect_document_id": false
96059610
},
96069611
{

hub/apps/develop/notifications/app-notifications/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ This section provides design and implementation guidance for app notifications i
3636
- [App notification progress bar and data binding](toast-progress-bar.md)
3737
- [App notification with pending update activation](toast-pending-update.md)
3838
- [Custom timestamps on app notifications](custom-timestamps-on-toasts.md)
39-
- [Grouping app notifications with collections](toast-collections.md)
39+
- [App notification collections](notification-collections.md)
4040
- [App notification headers](toast-headers.md)
4141
- [Notification listener: Access all notifications](notification-listener.md)
4242

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
description: Learn how to organize app notifications by creating, updating, or removing notification collections in Notification Center.
3+
title: App notification collections
4+
label: App notification collections
5+
template: detail.hbs
6+
ms.date: 07/28/2025
7+
ms.topic: how-to
8+
keywords: windows 11, windows app sdk, winappsdk, notification, collections, collection, group notifications, grouping notifications, group, organize, Notification Center
9+
ms.localizationpriority: medium
10+
---
11+
# App notification collections
12+
13+
Use collections to organize your app's notifications in Notification Center. Collections help users locate information more easily and allow developers to better manage their notifications.
14+
15+
A messaging app, for example, can separate notifications by chat group. Each group title ("Comp Sci 160A Project Chat", "Direct Messages", "Lacrosse Team Chat") is a separate collection. Notifications are grouped as if they were from a separate app, even though they all come from the same app. For a more subtle way to organize notifications, see [App notification headers](toast-headers.md).
16+
17+
![Collection Example with two different Groups of Notifications](images/toast-collection-example.png)
18+
19+
> [!NOTE]
20+
> The code examples in this article use the `Microsoft.Windows.AppNotifications` namespace to build notification content and the `Windows.UI.Notifications` namespace for collection management. These two namespaces can be used together in the same app.
21+
22+
For more information about app notifications, see [App notifications overview](index.md).
23+
24+
## Create a collection
25+
26+
When creating a collection, provide a display name and an icon, which are shown in Notification Center as part of the collection's title. Collections also require a launch argument so your app can navigate to the right location when the user clicks the collection title. Create the collection by calling [**SaveToastCollectionAsync**](/uwp/api/windows.ui.notifications.toastcollectionmanager.savetoastcollectionasync).
27+
28+
```csharp
29+
using Windows.UI.Notifications;
30+
31+
var collection = new ToastCollection(
32+
"MyToastCollection",
33+
"Work Email",
34+
"NavigateToWorkEmailInbox",
35+
new Uri("ms-appx:///Assets/workEmail.png"));
36+
37+
await ToastNotificationManager.GetDefault()
38+
.GetToastCollectionManager()
39+
.SaveToastCollectionAsync(collection);
40+
```
41+
42+
## Send a notification to a collection
43+
44+
Use [**AppNotificationBuilder**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.builder.appnotificationbuilder) to construct the notification content, then call [**GetToastNotifierForToastCollectionIdAsync**](/uwp/api/windows.ui.notifications.toastnotificationmanagerforuser.gettoastnotifierfortoastcollectionidasync) to get a notifier scoped to the collection.
45+
46+
```csharp
47+
using Microsoft.Windows.AppNotifications.Builder;
48+
using Windows.UI.Notifications;
49+
using Windows.Data.Xml.Dom;
50+
51+
// Build notification content with Windows App SDK
52+
var payload = new AppNotificationBuilder()
53+
.AddText("Adam sent a message to the group")
54+
.BuildNotification()
55+
.Payload;
56+
57+
// Deliver to a collection using the WinRT API
58+
var doc = new XmlDocument();
59+
doc.LoadXml(payload);
60+
var toast = new ToastNotification(doc);
61+
62+
var notifier = await ToastNotificationManager.GetDefault()
63+
.GetToastNotifierForToastCollectionIdAsync("MyToastCollection");
64+
notifier.Show(toast);
65+
```
66+
67+
## List all collections
68+
69+
Retrieve all collections created for your app by calling [**FindAllToastCollectionsAsync**](/uwp/api/windows.ui.notifications.toastcollectionmanager.findalltoastcollectionsasync).
70+
71+
```csharp
72+
var collectionManager = ToastNotificationManager.GetDefault().GetToastCollectionManager();
73+
var collections = await collectionManager.FindAllToastCollectionsAsync();
74+
```
75+
76+
## Update a collection
77+
78+
Update a collection by creating a new [**ToastCollection**](/uwp/api/windows.ui.notifications.toastcollection) instance with the same ID and calling [**SaveToastCollectionAsync**](/uwp/api/windows.ui.notifications.toastcollectionmanager.savetoastcollectionasync).
79+
80+
```csharp
81+
var collectionManager = ToastNotificationManager.GetDefault().GetToastCollectionManager();
82+
83+
var updatedCollection = new ToastCollection(
84+
"MyToastCollection",
85+
"Updated Display Name",
86+
"UpdatedLaunchArgs",
87+
new Uri("ms-appx:///Assets/updatedPicture.png"));
88+
89+
await collectionManager.SaveToastCollectionAsync(updatedCollection);
90+
```
91+
92+
## Remove a collection
93+
94+
Remove a collection by calling [**RemoveToastCollectionAsync**](/uwp/api/windows.ui.notifications.toastcollectionmanager.removetoastcollectionasync) with the collection ID. Any notifications in the collection are also removed from Notification Center.
95+
96+
```csharp
97+
var collectionManager = ToastNotificationManager.GetDefault().GetToastCollectionManager();
98+
await collectionManager.RemoveToastCollectionAsync("MyToastCollection");
99+
```
100+
101+
## Remove notifications within a collection
102+
103+
Use the **Tag** and **Group** properties to identify and remove individual notifications within a collection by calling [**Remove**](/uwp/api/windows.ui.notifications.toastnotificationhistory.remove), or clear all notifications at once with [**Clear**](/uwp/api/windows.ui.notifications.toastnotificationhistory.clear).
104+
105+
```csharp
106+
var collectionHistory = await ToastNotificationManager.GetDefault()
107+
.GetHistoryForToastCollectionAsync("MyToastCollection");
108+
109+
// Remove a specific notification
110+
collectionHistory.Remove(tag, group);
111+
112+
// Or clear all notifications in the collection
113+
collectionHistory.Clear();
114+
```
115+
116+
## See also
117+
118+
- [App notifications overview](index.md)

hub/apps/develop/notifications/app-notifications/scheduled-notification.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ Scheduled app notifications have a delivery window of 5 minutes. If the computer
1818

1919
For more information about app notifications, see [App notifications overview](index.md).
2020

21+
> [!NOTE]
22+
> The code examples in this article use the `Microsoft.Windows.AppNotifications` namespace to build notification content and the `Windows.UI.Notifications` namespace for scheduling. These two namespaces can be used together in the same app.
23+
2124

2225
## Schedule the notification
2326

24-
To schedule a notification for a future time, use [**AppNotificationBuilder**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.builder.appnotificationbuilder) to define the notification content and the [**ScheduledToastNotification**](/uwp/api/Windows.UI.Notifications.ScheduledToastNotification) API to schedule it. The following example schedules a notification to appear 10 seconds from now.
27+
To schedule a notification for a future time, use [**AppNotificationBuilder**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.builder.appnotificationbuilder) to define the notification content, then call [**AddToSchedule**](/uwp/api/windows.ui.notifications.toastnotifier.addtoschedule) with a [**ScheduledToastNotification**](/uwp/api/Windows.UI.Notifications.ScheduledToastNotification). The following example schedules a notification to appear 10 seconds from now.
2528

2629
```csharp
2730
using Microsoft.Windows.AppNotifications.Builder;
@@ -50,7 +53,7 @@ The **Tag** and **Group** properties act as a composite primary key for the noti
5053

5154
## Cancel scheduled notifications
5255

53-
To cancel a scheduled notification, retrieve the list of scheduled notifications from the [**ToastNotificationManager**](/uwp/api/Windows.UI.Notifications.ToastNotificationManager) and remove the one matching the tag you specified earlier.
56+
To cancel a scheduled notification, call [**GetScheduledToastNotifications**](/uwp/api/windows.ui.notifications.toastnotifier.getscheduledtoastnotifications) to retrieve the list of pending notifications, then call [**RemoveFromSchedule**](/uwp/api/windows.ui.notifications.toastnotifier.removefromschedule) on the one matching the tag you specified earlier.
5457

5558
```csharp
5659
var notifier = ToastNotificationManager.CreateToastNotifier();

hub/apps/develop/notifications/app-notifications/toast-collections.md

Lines changed: 0 additions & 218 deletions
This file was deleted.

0 commit comments

Comments
 (0)