Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion DesktopToast/ToastManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,19 @@ private static async Task CheckInstallShortcut(ToastRequest request)
/// <returns>Result of showing a toast</returns>
private static async Task<ToastResult> ShowBaseAsync(XmlDocument document, string appId)
{
var notifier = ToastNotificationManager.CreateToastNotifier(appId);
switch (notifier.Setting)
{
case NotificationSetting.DisabledForApplication:
return ToastResult.DisabledForApplication;
case NotificationSetting.DisabledForUser:
return ToastResult.DisabledForUser;
case NotificationSetting.DisabledByGroupPolicy:
return ToastResult.DisabledByGroupPolicy;
case NotificationSetting.DisabledByManifest:
return ToastResult.DisabledByManifest;
}

// Create a toast and prepare to handle toast events.
var toast = new ToastNotification(document);
var tcs = new TaskCompletionSource<ToastResult>();
Expand Down Expand Up @@ -368,7 +381,7 @@ private static async Task<ToastResult> ShowBaseAsync(XmlDocument document, strin
toast.Failed += failed;

// Show a toast.
ToastNotificationManager.CreateToastNotifier(appId).Show(toast);
notifier.Show(toast);

// Wait for the result.
var result = await tcs.Task;
Expand Down
24 changes: 24 additions & 0 deletions DesktopToast/ToastResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@ public enum ToastResult
/// </summary>
Unavailable = 0,

/// <summary>
/// The user has disabled notifications for this app.
/// </summary>
/// <remarks>This corresponds to NotificationSetting.DisabledForApplication setting.</remarks>
DisabledForApplication,

/// <summary>
/// The user or administrator has disabled all notifications for this user on this computer.
/// </summary>
/// <remarks>This corresponds to NotificationSetting.DisabledForUser setting.</remarks>
DisabledForUser,

/// <summary>
/// An administrator has disabled all notifications on this computer through group policy.
/// </summary>
/// <remarks>This corresponds to NotificationSetting.DisabledByGroupPolicy setting.</remarks>
DisabledByGroupPolicy,

/// <summary>
/// This app has not declared itself toast capable in its package.appxmanifest file.
/// </summary>
/// <remarks>This corresponds to NotificationSetting.DisabledByManifest setting.</remarks>
DisabledByManifest,

/// <summary>
/// Toast request is invalid.
/// </summary>
Expand Down