diff --git a/DesktopToast/ToastManager.cs b/DesktopToast/ToastManager.cs
index feb9b20..9314505 100644
--- a/DesktopToast/ToastManager.cs
+++ b/DesktopToast/ToastManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
@@ -15,12 +15,42 @@ namespace DesktopToast
///
public class ToastManager
{
+ ///
+ /// clear toast notification for appId
+ ///
+ /// Toast appId
+ public static void Clear(string appId)
+ {
+ try
+ {
+ ToastNotificationManager.History.Clear(appId);
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ ///
+ /// remove a toast.
+ ///
+ /// Toast tag
+ /// Toast group
+ /// Toast appId
+ public static void Remove(string tag, string group, string appId)
+ {
+ try
+ {
+ ToastNotificationManager.History.Remove(tag, group, appId);
+ }
+ catch (Exception ex)
+ {
+ }
+ }
///
/// Shows a toast.
///
/// Toast request
/// Result of showing a toast
- public static async Task ShowAsync(ToastRequest request)
+ public static async Task ShowAsync(ToastRequest request, string tag=null, string group=null)
{
if (request == null)
throw new ArgumentNullException(nameof(request));
@@ -38,7 +68,7 @@ public static async Task ShowAsync(ToastRequest request)
if (document == null)
return ToastResult.Invalid;
- return await ShowBaseAsync(document, request.AppId);
+ return await ShowBaseAsync(document, request.AppId, tag, group);
}
///
@@ -78,7 +108,7 @@ public static async Task ShowAsync(XmlDocument document, string app
if (!OsVersion.IsEightOrNewer)
return ToastResult.Unavailable;
- return await ShowBaseAsync(document, appId);
+ return await ShowBaseAsync(document, appId,null, null);
}
#region Document
@@ -332,7 +362,7 @@ private static async Task CheckInstallShortcut(ToastRequest request)
/// Toast document
/// AppUserModelID
/// Result of showing a toast
- private static async Task ShowBaseAsync(XmlDocument document, string appId)
+ private static async Task ShowBaseAsync(XmlDocument document, string appId, string tag, string group)
{
// Create a toast and prepare to handle toast events.
var toast = new ToastNotification(document);
@@ -366,10 +396,13 @@ private static async Task ShowBaseAsync(XmlDocument document, strin
tcs.SetResult(ToastResult.Failed);
};
toast.Failed += failed;
+ if (!string.IsNullOrEmpty(tag))
+ toast.Tag = tag;
+ if (!string.IsNullOrEmpty(group))
+ toast.Group = group;
// Show a toast.
ToastNotificationManager.CreateToastNotifier(appId).Show(toast);
-
// Wait for the result.
var result = await tcs.Task;
@@ -384,4 +417,4 @@ private static async Task ShowBaseAsync(XmlDocument document, strin
#endregion
}
-}
\ No newline at end of file
+}