diff --git a/src/FlashCom/App.cpp b/src/FlashCom/App.cpp index 272274e..0961176 100644 --- a/src/FlashCom/App.cpp +++ b/src/FlashCom/App.cpp @@ -12,22 +12,39 @@ namespace void ShowStartupNotification() { - winrt::WDXD::XmlDocument notificationPayload; - notificationPayload.LoadXml(LR""""( - - - - FlashCom is running! - Press Win+Space to invoke. - Manage settings from the system tray icon. - - - -)""""); - winrt::WUIN::ToastNotification notification{ notificationPayload }; - auto notificationManager{ winrt::WUIN::ToastNotificationManager::GetDefault() }; - auto notifier{ notificationManager.CreateToastNotifier() }; - notifier.Show(notification); + try + { + winrt::WDXD::XmlDocument notificationPayload; + notificationPayload.LoadXml(LR""""( + + + + FlashCom is running! + Press Win+Space to invoke. + Manage settings from the system tray icon. + + + + )""""); + winrt::WUIN::ToastNotification notification{ notificationPayload }; + auto notificationManager{ winrt::WUIN::ToastNotificationManager::GetDefault() }; + auto notifier{ notificationManager.CreateToastNotifier() }; + notifier.Show(notification); + } + catch (const winrt::hresult_error& error) + { + // Currently, we can't fire toasts from an unpacked app. + // See issue at github.com/haydenmc/FlashCom/issues/37 + if (error.code() != 0x80070490) // ERROR_NOT_FOUND + { + throw error; + } + else + { + SPDLOG_WARN("App::ShowStartupNotification - Cannot fire toast " + "notification from unpackaged app."); + } + } } }