Skip to content

Commit 7f99250

Browse files
drewbatgitCopilot
andcommitted
Remove remaining Community Toolkit references from code snippets
- adaptive-interactive-toasts.md: Remove stale ToastContentBuilder() lines left above AppNotificationBuilder code in two button snippet examples - send-local-toast-cpp-uwp.md: Rewrite expiration, tag/group, and clear snippets from ToastContentBuilder/Compat to standard C++/WinRT XML APIs - includes/nuget-package.md: Delete unused Community Toolkit NuGet package instructions (zero references from any doc file) Co-authored-by: Copilot <[email protected]>
1 parent 226b5e3 commit 7f99250

3 files changed

Lines changed: 60 additions & 38 deletions

File tree

hub/apps/develop/notifications/app-notifications/adaptive-interactive-toasts.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,14 @@ Buttons can activate an app in the following ways:
383383
### [Windows App SDK](#tab/appsdk)
384384

385385
```csharp
386-
new ToastContentBuilder()
387-
var builder = new AppNotificationBuilder()
388-
.AddText("New product in stock!")
389-
.AddButton(new AppNotificationButton("See more details")
390-
.AddArgument("action", "viewDetails"))
391-
.AddArgument("contentId", "351")
392-
.AddButton(new AppNotificationButton("Remind me later")
393-
.AddArgument("action", "remindLater"))
394-
.AddArgument("contentId", "351");
386+
var builder = new AppNotificationBuilder()
387+
.AddText("New product in stock!")
388+
.AddButton(new AppNotificationButton("See more details")
389+
.AddArgument("action", "viewDetails"))
390+
.AddArgument("contentId", "351")
391+
.AddButton(new AppNotificationButton("Remind me later")
392+
.AddArgument("action", "remindLater"))
393+
.AddArgument("contentId", "351");
395394
```
396395

397396
### [XML](#tab/xml)
@@ -423,18 +422,17 @@ You can add icons to your buttons. These icons are white transparent 16x16 pixel
423422
![Screenshot of an app notification that uses buttons with icons.](images/toast-content-button-icons.png)
424423

425424
```csharp
426-
new ToastContentBuilder()
427-
var builder = new AppNotificationBuilder()
428-
.AddText("Return books to the library.")
429-
.AddButton(new AppNotificationButton("Accept")
430-
.AddArgument("action", "accept")
431-
.SetIcon(new Uri("ms-appx:///Images/Accept.png")))
432-
.AddButton(new AppNotificationButton("Snooze")
433-
.AddArgument("action", "snooze")
434-
.SetIcon(new Uri("ms-appx:///Images/Snooze.png")))
435-
.AddButton(new AppNotificationButton("Dismiss")
436-
.AddArgument("action", "dismiss")
437-
.SetIcon(new Uri("ms-appx:///Images/Dismiss.png")));
425+
var builder = new AppNotificationBuilder()
426+
.AddText("Return books to the library.")
427+
.AddButton(new AppNotificationButton("Accept")
428+
.AddArgument("action", "accept")
429+
.SetIcon(new Uri("ms-appx:///Images/Accept.png")))
430+
.AddButton(new AppNotificationButton("Snooze")
431+
.AddArgument("action", "snooze")
432+
.SetIcon(new Uri("ms-appx:///Images/Snooze.png")))
433+
.AddButton(new AppNotificationButton("Dismiss")
434+
.AddArgument("action", "dismiss")
435+
.SetIcon(new Uri("ms-appx:///Images/Dismiss.png")));
438436
```
439437

440438

hub/apps/develop/notifications/app-notifications/includes/nuget-package.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

hub/apps/develop/notifications/app-notifications/send-local-toast-cpp-uwp.md

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,25 @@ However, if the message in your notification is only relevant for a period of ti
290290
> The default and maximum expiration time for local app notifications is 3 days.
291291
292292
```cpp
293-
// Create toast content and show the toast!
294-
(ref new ToastContentBuilder())
295-
->AddText("Expires in 2 days...")
296-
->Show(toast =>
297-
{
298-
toast->ExpirationTime = DateTime::Now->AddDays(2);
299-
});
293+
// Construct the XML toast template
294+
XmlDocument doc;
295+
doc.LoadXml(L"\
296+
<toast>\
297+
<visual>\
298+
<binding template=\"ToastGeneric\">\
299+
<text>Expires in 2 days...</text>\
300+
</binding>\
301+
</visual>\
302+
</toast>");
303+
304+
// Construct the notification and set expiration time to 2 days
305+
winrt::Windows::UI::Notifications::ToastNotification notif{ doc };
306+
notif.ExpirationTime(winrt::clock::now() + std::chrono::hours{ 48 });
307+
308+
// Show the notification
309+
winrt::Windows::UI::Notifications::ToastNotificationManager toastManager{};
310+
ToastNotifier toastNotifier{ toastManager.CreateToastNotifier() };
311+
toastNotifier.Show(notif);
300312
```
301313
302314
## Provide a primary key for your app notification
@@ -308,14 +320,26 @@ To see more details on replacing/removing already delivered app notifications, p
308320
Tag and Group combined act as a composite primary key. Group is the more generic identifier, where you can assign groups like "wallPosts", "messages", "friendRequests", etc. And then Tag should uniquely identify the notification itself from within the group. By using a generic group, you can then remove all notifications from that group by using the [RemoveGroup API](/uwp/api/Windows.UI.Notifications.ToastNotificationHistory#Windows_UI_Notifications_ToastNotificationHistory_RemoveGroup_System_String_).
309321
310322
```cpp
311-
// Create toast content and show the toast!
312-
(ref new ToastContentBuilder())
313-
->AddText("New post on your wall!")
314-
->Show(toast =>
315-
{
316-
toast.Tag = "18365";
317-
toast.Group = "wallPosts";
318-
});
323+
// Construct the XML toast template
324+
XmlDocument doc;
325+
doc.LoadXml(L"\
326+
<toast>\
327+
<visual>\
328+
<binding template=\"ToastGeneric\">\
329+
<text>New post on your wall!</text>\
330+
</binding>\
331+
</visual>\
332+
</toast>");
333+
334+
// Construct the notification and assign tag and group
335+
winrt::Windows::UI::Notifications::ToastNotification notif{ doc };
336+
notif.Tag(L"18365");
337+
notif.Group(L"wallPosts");
338+
339+
// Show the notification
340+
winrt::Windows::UI::Notifications::ToastNotificationManager toastManager{};
341+
ToastNotifier toastNotifier{ toastManager.CreateToastNotifier() };
342+
toastNotifier.Show(notif);
319343
```
320344

321345

@@ -336,7 +360,8 @@ Here's an example of what a messaging app should do…
336360
To learn about clearing all notifications or removing specific notifications, see [Quickstart: Managing app notifications in action center (XAML)](/previous-versions/windows/apps/dn631260(v=win.10)).
337361

338362
```cpp
339-
ToastNotificationManagerCompat::History->Clear();
363+
winrt::Windows::UI::Notifications::ToastNotificationManager toastManager{};
364+
toastManager.History().Clear();
340365
```
341366

342367
## Resources

0 commit comments

Comments
 (0)