From 9c31b900215b0dc9166a8b9fa727012dd29c6173 Mon Sep 17 00:00:00 2001 From: Robin Krom Date: Thu, 16 Apr 2020 21:19:07 +0200 Subject: [PATCH] Fix #182, the notifications don't work due to a quirk in the Windows API. --- GreenshotWin10Plugin/ToastNotificationService.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/GreenshotWin10Plugin/ToastNotificationService.cs b/GreenshotWin10Plugin/ToastNotificationService.cs index 413a51c00..5f51d7fd6 100644 --- a/GreenshotWin10Plugin/ToastNotificationService.cs +++ b/GreenshotWin10Plugin/ToastNotificationService.cs @@ -81,10 +81,19 @@ namespace GreenshotWin10Plugin } // Prepare the toast notifier. Be sure to specify the AppUserModelId on your application's shortcut! var toastNotifier = DesktopNotificationManagerCompat.CreateToastNotifier(); - if (toastNotifier.Setting != NotificationSetting.Enabled) + + // Here is an interesting article on reading the settings: https://www.rudyhuyn.com/blog/2018/02/10/toastnotifier-and-settings-careful-with-non-uwp-applications/ + try { - Log.DebugFormat("Ignored toast due to {0}", toastNotifier.Setting); - return; + if (toastNotifier.Setting != NotificationSetting.Enabled) + { + Log.DebugFormat("Ignored toast due to {0}", toastNotifier.Setting); + return; + } + } + catch (Exception) + { + Log.Info("Ignoring exception as this means that there was no stored settings."); } // Get a toast XML template