Skip to content

Commit 9f5902a

Browse files
drewbatgitCopilot
andcommitted
Remove Community Toolkit notification references from content files
Remove all Community Toolkit tab sections and prose references from 9 app notification content files. The Windows Community Toolkit no longer supports notifications, so these references are being removed. - Remove 37 toolkit tab groups (code tabs + content) - Update prose to remove toolkit version requirements and references - Remove toolkit GitHub links from Related Topics sections - Update adaptive-interactive-toasts.md intro from 3 methods to 2 Files changed: adaptive-interactive-toasts.md, send-local-toast.md, scheduled-toast.md, toast-progress-bar.md, toast-pending-update.md, toast-collections.md, custom-audio-on-toasts.md, toast-headers.md, custom-timestamps-on-toasts.md Co-authored-by: Copilot <[email protected]>
1 parent 8f37124 commit 9f5902a

9 files changed

Lines changed: 2185 additions & 3074 deletions

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

Lines changed: 979 additions & 1442 deletions
Large diffs are not rendered by default.
Lines changed: 87 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,87 @@
1-
---
2-
description: Learn how to use custom audio on your app notifications to let your app express your brand's unique sound effects.
3-
title: Custom audio on app notifications
4-
label: Custom audio on app notifications
5-
template: detail.hbs
6-
ms.date: 12/15/2017
7-
ms.topic: article
8-
keywords: windows 10, windows 11, uwp, windows app sdk, winappsdk, toast, custom audio, notification, audio, sound
9-
ms.localizationpriority: medium
10-
---
11-
# Custom audio on app notifications
12-
13-
App notifications can use custom audio, which lets your app express your brand's unique sound effects. For example, a messaging app can use their own messaging sound on their app notifications, so that the user can instantly know that they received a notification from the app, rather than hearing the generic notification sound.
14-
15-
## Install notification libraries
16-
17-
For Windows App SDK apps, use the `AppNotificationBuilder` from the `Microsoft.Windows.AppNotifications.Builder` namespace, which is included in the Windows App SDK — no additional NuGet packages are required.
18-
19-
For apps using the Community Toolkit, install the [Microsoft.Toolkit.Uwp.Notifications](https://www.nuget.org/packages/Microsoft.Toolkit.Uwp.Notifications/) NuGet package, which provides an object model for the notification XML content.
20-
21-
## Add namespace declarations
22-
23-
### [Windows App SDK](#tab/appsdk)
24-
25-
```csharp
26-
using Microsoft.Windows.AppNotifications;
27-
using Microsoft.Windows.AppNotifications.Builder;
28-
```
29-
30-
### [Community Toolkit](#tab/toolkit)
31-
32-
```csharp
33-
using Microsoft.Toolkit.Uwp.Notifications;
34-
```
35-
36-
---
37-
38-
## Add the custom audio
39-
40-
Windows Mobile has always supported custom audio in app notifications. However, Desktop only added support for custom audio in Version 1511 (build 10586). If you send a Toast that contains custom audio to a Desktop device before Version 1511, the toast will be silent. Therefore, for Desktop pre-Version 1511, you should NOT include the custom audio in your app notification, so that the notification will at least use the default notification sound.
41-
42-
**Known Issue**: If you're using Desktop Version 1511, the custom toast audio will only work if your app is installed via the Store. That means you cannot locally test your custom audio on Desktop before submitting to the Store - but the audio will work fine once installed from the Store. We fixed this in the Anniversary Update, so that custom audio from your locally deployed app will work correctly.
43-
44-
### [Windows App SDK](#tab/appsdk)
45-
46-
```csharp
47-
var builder = new AppNotificationBuilder()
48-
.AddText("New message")
49-
.SetAudioUri(new Uri("ms-appx:///Assets/Audio/CustomToastAudio.m4a"));
50-
51-
var notification = builder.BuildNotification();
52-
AppNotificationManager.Default.Show(notification);
53-
```
54-
55-
### [Community Toolkit](#tab/toolkit)
56-
57-
```csharp
58-
var contentBuilder = new ToastContentBuilder()
59-
.AddText("New message");
60-
61-
62-
bool supportsCustomAudio = true;
63-
64-
// If we're running on Desktop before Version 1511, do NOT include custom audio
65-
// since it was not supported until Version 1511, and would result in a silent toast.
66-
if (AnalyticsInfo.VersionInfo.DeviceFamily.Equals("Windows.Desktop")
67-
&& !ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 2))
68-
{
69-
supportsCustomAudio = false;
70-
}
71-
72-
if (supportsCustomAudio)
73-
{
74-
contentBuilder.AddAudio(new Uri("ms-appx:///Assets/Audio/CustomToastAudio.m4a"));
75-
}
76-
77-
// Send the toast
78-
contentBuilder.Show();
79-
```
80-
81-
### [XML](#tab/xml)
82-
83-
```xml
84-
<toast>
85-
<visual>
86-
<binding template="ToastGeneric">
87-
<text>New message</text>
88-
</binding>
89-
</visual>
90-
<audio src="ms-appx:///Assets/Audio/CustomToastAudio.m4a"/>
91-
</toast>
92-
```
93-
94-
---
95-
96-
Supported audio file types include:
97-
98-
- .aac
99-
- .flac
100-
- .m4a
101-
- .mp3
102-
- .wav
103-
- .wma
104-
105-
Supported audio file sources:
106-
107-
- ms-appx:///
108-
- ms-resource
109-
110-
**Not** supported audio file sources:
111-
112-
- ms-appdata
113-
- http://, https://
114-
- C:/, F:/, etc.
115-
116-
117-
## Send the notification
118-
119-
Sending a notification with audio is the same as sending a regular notification. For Windows App SDK apps, use `AppNotificationManager.Default.Show()`. For Community Toolkit apps, call the `Show()` method on the builder. See [Send local toast](send-local-toast.md) to learn more.
120-
121-
122-
## Related topics
123-
124-
- [Full code sample on GitHub](https://github.com/WindowsNotifications/quickstart-toast-with-custom-audio)
125-
- [Send a local toast](send-local-toast.md)
126-
- [Toast content documentation](adaptive-interactive-toasts.md)
1+
---
2+
description: Learn how to use custom audio on your app notifications to let your app express your brand's unique sound effects.
3+
title: Custom audio on app notifications
4+
label: Custom audio on app notifications
5+
template: detail.hbs
6+
ms.date: 12/15/2017
7+
ms.topic: article
8+
keywords: windows 10, windows 11, uwp, windows app sdk, winappsdk, toast, custom audio, notification, audio, sound
9+
ms.localizationpriority: medium
10+
---
11+
# Custom audio on app notifications
12+
13+
App notifications can use custom audio, which lets your app express your brand's unique sound effects. For example, a messaging app can use their own messaging sound on their app notifications, so that the user can instantly know that they received a notification from the app, rather than hearing the generic notification sound.
14+
15+
## Add namespace declarations
16+
17+
For Windows App SDK apps, use the `AppNotificationBuilder` from the `Microsoft.Windows.AppNotifications.Builder` namespace, which is included in the Windows App SDK — no additional NuGet packages are required.
18+
19+
```csharp
20+
using Microsoft.Windows.AppNotifications;
21+
using Microsoft.Windows.AppNotifications.Builder;
22+
```
23+
24+
25+
## Add the custom audio
26+
27+
Windows Mobile has always supported custom audio in app notifications. However, Desktop only added support for custom audio in Version 1511 (build 10586). If you send a Toast that contains custom audio to a Desktop device before Version 1511, the toast will be silent. Therefore, for Desktop pre-Version 1511, you should NOT include the custom audio in your app notification, so that the notification will at least use the default notification sound.
28+
29+
**Known Issue**: If you're using Desktop Version 1511, the custom toast audio will only work if your app is installed via the Store. That means you cannot locally test your custom audio on Desktop before submitting to the Store - but the audio will work fine once installed from the Store. We fixed this in the Anniversary Update, so that custom audio from your locally deployed app will work correctly.
30+
31+
### [Windows App SDK](#tab/appsdk)
32+
33+
```csharp
34+
var builder = new AppNotificationBuilder()
35+
.AddText("New message")
36+
.SetAudioUri(new Uri("ms-appx:///Assets/Audio/CustomToastAudio.m4a"));
37+
38+
var notification = builder.BuildNotification();
39+
AppNotificationManager.Default.Show(notification);
40+
```
41+
42+
### [XML](#tab/xml)
43+
44+
```xml
45+
<toast>
46+
<visual>
47+
<binding template="ToastGeneric">
48+
<text>New message</text>
49+
</binding>
50+
</visual>
51+
<audio src="ms-appx:///Assets/Audio/CustomToastAudio.m4a"/>
52+
</toast>
53+
```
54+
55+
---
56+
57+
Supported audio file types include:
58+
59+
- .aac
60+
- .flac
61+
- .m4a
62+
- .mp3
63+
- .wav
64+
- .wma
65+
66+
Supported audio file sources:
67+
68+
- ms-appx:///
69+
- ms-resource
70+
71+
**Not** supported audio file sources:
72+
73+
- ms-appdata
74+
- http://, https://
75+
- C:/, F:/, etc.
76+
77+
78+
## Send the notification
79+
80+
Sending a notification with audio is the same as sending a regular notification. For Windows App SDK apps, use `AppNotificationManager.Default.Show()`. See [Send local toast](send-local-toast.md) to learn more.
81+
82+
83+
## Related topics
84+
85+
- [Full code sample on GitHub](https://github.com/WindowsNotifications/quickstart-toast-with-custom-audio)
86+
- [Send a local toast](send-local-toast.md)
87+
- [Toast content documentation](adaptive-interactive-toasts.md)
Lines changed: 76 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,77 @@
1-
---
2-
title: Custom timestamps on app notifications
3-
description: Learn how to override the default timestamp on an app notification with a custom timestamp that indicates when the message/information/content was generated.
4-
label: Custom timestamps on an notifications
5-
template: detail.hbs
6-
ms.date: 12/15/2017
7-
ms.topic: article
8-
keywords: windows 10, windows 11, windows app sdk, winappsdk, uwp, toast, custom timestamp, timestamp, notification, Action Center
9-
ms.localizationpriority: medium
10-
---
11-
# Custom timestamps on app notifications
12-
13-
By default, the timestamp on app notifications, which is visible within Notification Center, is set to the time that the notification was sent. You can optionally override the timestamp with your own custom date and time, so that the timestamp represents the time the message/information/content was actually created, rather than the time that the notification was sent. This also ensures that your notifications appear in the correct order within Notification Center, which is sorted by time. We recommend that most apps specify a custom timestamp.
14-
15-
This feature is available in Windows Build 15063 and later.
16-
17-
:::image type="content" source="images/toast-content-custom-timestamp.png" alt-text="App notification with custom timestamp":::
18-
19-
> [!NOTE]
20-
> The term "toast notification" is being replaced with "app notification". These terms both refer to the same feature of Windows, but over time we will phase out the use of "toast notification" in the documentation.
21-
22-
23-
To use a custom timestamp, simply assign the **displayTimestamp** property on the **toast** element of your app notification XML payload. Starting with Windows App SDK 1.2, you can add a custom timestamp to an app notification with the [Microsoft.Windows.AppNotifications.Builder](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.builder). For UWP apps, you can use version 1.4.0 or later of the [UWP Community Toolkit Notifications NuGet library](https://www.nuget.org/packages/Microsoft.Toolkit.Uwp.Notifications/). You can also specify the timestamp using raw xml.
24-
25-
26-
### [Windows App SDK](#tab/appsdk)
27-
28-
```csharp
29-
var builder = new AppNotificationBuilder()
30-
.AddText("Matt sent you a friend request")
31-
.AddText("Hey, wanna dress up as wizards and ride around on hoverboards?")
32-
.SetTimeStamp(new DateTime(2017, 04, 15, 19, 45, 00, DateTimeKind.Utc));
33-
```
34-
35-
### [Community Toolkit](#tab/toolkit)
36-
37-
```csharp
38-
var builder = new ToastContentBuilder()
39-
.AddText("Matt sent you a friend request")
40-
.AddText("Hey, wanna dress up as wizards and ride around on hoverboards?")
41-
.AddCustomTimeStamp(new DateTime(2017, 04, 15, 19, 45, 00, DateTimeKind.Utc));
42-
```
43-
44-
### [XML](#tab/xml)
45-
46-
```xml
47-
<toast displayTimestamp='2017-04-15T12:45:00-07:00'>
48-
<visual>
49-
<binding template='ToastGeneric'>
50-
<text>Matt sent you a friend request</text>
51-
<text>Hey, wanna dress up as wizards and ride around on hoverboards?</text>
52-
</binding>
53-
</visual>
54-
</toast>
55-
```
56-
57-
---
58-
59-
If you are using XML, the date must be formatted in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).
60-
61-
> [!NOTE]
62-
> You can only use at most 3 decimal places on the seconds (although realistically there's no value in providing anything that granular). If you provide more, the payload will be invalid and you will receive the "New notification" notification.
63-
64-
65-
## Usage guidance
66-
67-
In general, we recommend that most apps specify a custom timestamp. This ensures that the notification's timestamp accurately represents when the message/information/content was generated, regardless of network delays, airplane mode, or the fixed interval of periodic background tasks.
68-
69-
For example, a news app might run a background task every 15 minutes that checks for new articles and displays notifications. Before custom timestamps, the timestamp corresponded to when the app notification was generated (therefore always in 15 minute intervals). However, now the app can set the timestamp to the time the article was actually published. Similarly, email apps and social network apps can benefit from this feature if a similar pattern of periodic pulling is used for their notifications.
70-
71-
Additionally, providing a custom timestamp ensures that the timestamp is correct even if the user was disconnected from the internet. For example, when the user turns their computer on and your background task runs, you can finally ensure that the timestamp on your notifications represents the time that the messages were sent, rather than the time the user turned on their computer.
72-
73-
74-
## Default timestamp
75-
76-
If you don't provide a custom timestamp, we use the time that your notification was sent.
77-
78-
If you sent a push notification through WNS, we use the time when the notification was received by WNS server (so any latency on delivering the notification to the device won't impact the timestamp).
79-
80-
If you sent a local notification, we use the time when the notification platform received the notification (which should be immediately).
81-
82-
83-
## Related topics
84-
85-
- [Send a local toast](send-local-toast.md)
1+
---
2+
title: Custom timestamps on app notifications
3+
description: Learn how to override the default timestamp on an app notification with a custom timestamp that indicates when the message/information/content was generated.
4+
label: Custom timestamps on an notifications
5+
template: detail.hbs
6+
ms.date: 12/15/2017
7+
ms.topic: article
8+
keywords: windows 10, windows 11, windows app sdk, winappsdk, uwp, toast, custom timestamp, timestamp, notification, Action Center
9+
ms.localizationpriority: medium
10+
---
11+
# Custom timestamps on app notifications
12+
13+
By default, the timestamp on app notifications, which is visible within Notification Center, is set to the time that the notification was sent. You can optionally override the timestamp with your own custom date and time, so that the timestamp represents the time the message/information/content was actually created, rather than the time that the notification was sent. This also ensures that your notifications appear in the correct order within Notification Center, which is sorted by time. We recommend that most apps specify a custom timestamp.
14+
15+
This feature is available in Windows Build 15063 and later.
16+
17+
:::image type="content" source="images/toast-content-custom-timestamp.png" alt-text="App notification with custom timestamp":::
18+
19+
> [!NOTE]
20+
> The term "toast notification" is being replaced with "app notification". These terms both refer to the same feature of Windows, but over time we will phase out the use of "toast notification" in the documentation.
21+
22+
23+
To use a custom timestamp, simply assign the **displayTimestamp** property on the **toast** element of your app notification XML payload. Starting with Windows App SDK 1.2, you can add a custom timestamp to an app notification with the [Microsoft.Windows.AppNotifications.Builder](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.builder). You can also specify the timestamp using raw XML.
24+
25+
26+
### [Windows App SDK](#tab/appsdk)
27+
28+
```csharp
29+
var builder = new AppNotificationBuilder()
30+
.AddText("Matt sent you a friend request")
31+
.AddText("Hey, wanna dress up as wizards and ride around on hoverboards?")
32+
.SetTimeStamp(new DateTime(2017, 04, 15, 19, 45, 00, DateTimeKind.Utc));
33+
```
34+
35+
### [XML](#tab/xml)
36+
37+
```xml
38+
<toast displayTimestamp='2017-04-15T12:45:00-07:00'>
39+
<visual>
40+
<binding template='ToastGeneric'>
41+
<text>Matt sent you a friend request</text>
42+
<text>Hey, wanna dress up as wizards and ride around on hoverboards?</text>
43+
</binding>
44+
</visual>
45+
</toast>
46+
```
47+
48+
---
49+
50+
If you are using XML, the date must be formatted in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).
51+
52+
> [!NOTE]
53+
> You can only use at most 3 decimal places on the seconds (although realistically there's no value in providing anything that granular). If you provide more, the payload will be invalid and you will receive the "New notification" notification.
54+
55+
56+
## Usage guidance
57+
58+
In general, we recommend that most apps specify a custom timestamp. This ensures that the notification's timestamp accurately represents when the message/information/content was generated, regardless of network delays, airplane mode, or the fixed interval of periodic background tasks.
59+
60+
For example, a news app might run a background task every 15 minutes that checks for new articles and displays notifications. Before custom timestamps, the timestamp corresponded to when the app notification was generated (therefore always in 15 minute intervals). However, now the app can set the timestamp to the time the article was actually published. Similarly, email apps and social network apps can benefit from this feature if a similar pattern of periodic pulling is used for their notifications.
61+
62+
Additionally, providing a custom timestamp ensures that the timestamp is correct even if the user was disconnected from the internet. For example, when the user turns their computer on and your background task runs, you can finally ensure that the timestamp on your notifications represents the time that the messages were sent, rather than the time the user turned on their computer.
63+
64+
65+
## Default timestamp
66+
67+
If you don't provide a custom timestamp, we use the time that your notification was sent.
68+
69+
If you sent a push notification through WNS, we use the time when the notification was received by WNS server (so any latency on delivering the notification to the device won't impact the timestamp).
70+
71+
If you sent a local notification, we use the time when the notification platform received the notification (which should be immediately).
72+
73+
74+
## Related topics
75+
76+
- [Send a local toast](send-local-toast.md)
8677
- [App notification content documentation](adaptive-interactive-toasts.md)

0 commit comments

Comments
 (0)