Skip to content

Commit 9df166e

Browse files
Send notifications even when we're unpackaged (#20013)
## Summary of the Pull Request Targets #20010 Manually assign an AUMID to our process when we're running unpackaged. Main difference from #19937 is what AUMID we use. Before, it was per branding, but the `WindowEmperor` already appends an exe path hash for unpackaged instances to prevent crosstalk. Here, we're just using the same pattern: `Microsoft.WindowsTerminal.<hash>`. Heavily based on #19937 Co-authored by @zadjii-msft
1 parent aeb531f commit 9df166e

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/cascadia/TerminalApp/DesktopNotification.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "pch.h"
55
#include "DesktopNotification.h"
66

7+
#include <WtExeUtils.h>
8+
79
using namespace winrt::Windows::UI::Notifications;
810
using namespace winrt::Windows::Data::Xml::Dom;
911

@@ -96,10 +98,26 @@ namespace winrt::TerminalApp::implementation
9698
}
9799

98100
// For packaged apps, CreateToastNotifier() uses the package identity automatically.
99-
// For unpackaged apps, we need to provide an AUMID, but that case is less common
100-
// and toast notifications may not be supported without additional setup.
101-
auto notifier = ToastNotificationManager::CreateToastNotifier();
102-
notifier.Show(toast);
101+
// For unpackaged apps, we must pass the explicit AUMID that was registered
102+
// at startup via SetCurrentProcessExplicitAppUserModelID.
103+
winrt::Windows::UI::Notifications::ToastNotifier notifier{ nullptr };
104+
if (IsPackaged())
105+
{
106+
notifier = ToastNotificationManager::CreateToastNotifier();
107+
}
108+
else
109+
{
110+
// Retrieve the AUMID that was set by WindowEmperor at startup.
111+
wil::unique_cotaskmem_string aumid;
112+
if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&aumid)))
113+
{
114+
notifier = ToastNotificationManager::CreateToastNotifier(aumid.get());
115+
}
116+
}
117+
if (notifier)
118+
{
119+
notifier.Show(toast);
120+
}
103121
}
104122
catch (...)
105123
{

0 commit comments

Comments
 (0)