From b68be5c583e7f8ec956f3c91cfa464c8b00162c5 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 15 Mar 2016 17:10:24 -0700 Subject: [PATCH] :checkered_flag: Notify only when enabled - Previously, we'd attempt to create a notification no matter what the user's configuration was. Microsoft advises against that, because it can create race conditions if notifications are disabled. - This fixes the issue. Closes https://github.com/atom/electron/issues/4681 --- brightray/browser/win/windows_toast_notification.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/brightray/browser/win/windows_toast_notification.cc b/brightray/browser/win/windows_toast_notification.cc index 74cd74eceb..a744c88815 100644 --- a/brightray/browser/win/windows_toast_notification.cc +++ b/brightray/browser/win/windows_toast_notification.cc @@ -89,7 +89,16 @@ void WindowsToastNotification::Show( const bool silent) { auto presenter_win = static_cast(presenter()); std::wstring icon_path = presenter_win->SaveIconToFilesystem(icon, icon_url); - + + // Ask Windows for the current notification settings + // If not allowed, we return here (0 = enabled) + ABI::Windows::UI::Notifications::NotificationSetting setting; + toast_notifier_->get_Setting(&setting); + if (setting != 0) { + NotificationFailed(); + return; + } + ComPtr toast_xml; if(FAILED(GetToastXml(toast_manager_.Get(), title, msg, icon_path, silent, &toast_xml))) { NotificationFailed();