-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Send notifications even when we're unpackaged #20013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
| #include "pch.h" | ||
| #include "DesktopNotification.h" | ||
|
|
||
| #include <WtExeUtils.h> | ||
|
|
||
| using namespace winrt::Windows::UI::Notifications; | ||
| using namespace winrt::Windows::Data::Xml::Dom; | ||
|
|
||
|
|
@@ -96,10 +98,26 @@ namespace winrt::TerminalApp::implementation | |
| } | ||
|
|
||
| // For packaged apps, CreateToastNotifier() uses the package identity automatically. | ||
| // For unpackaged apps, we need to provide an AUMID, but that case is less common | ||
| // and toast notifications may not be supported without additional setup. | ||
| auto notifier = ToastNotificationManager::CreateToastNotifier(); | ||
| notifier.Show(toast); | ||
| // For unpackaged apps, we must pass the explicit AUMID that was registered | ||
| // at startup via SetCurrentProcessExplicitAppUserModelID. | ||
| winrt::Windows::UI::Notifications::ToastNotifier notifier{ nullptr }; | ||
| if (IsPackaged()) | ||
| { | ||
| notifier = ToastNotificationManager::CreateToastNotifier(); | ||
| } | ||
| else | ||
| { | ||
| // Retrieve the AUMID that was set by WindowEmperor at startup. | ||
| wil::unique_cotaskmem_string aumid; | ||
| if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&aumid))) | ||
| { | ||
| notifier = ToastNotificationManager::CreateToastNotifier(aumid.get()); | ||
| } | ||
| } | ||
| if (notifier) | ||
| { | ||
|
Comment on lines
+117
to
+118
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do those WinRT (?) functions really return null instead of throwing an HRESULT?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if It's more there for when this fails... if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&aumid))) |
||
| notifier.Show(toast); | ||
| } | ||
| } | ||
| catch (...) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make the other block a separate PR to main, you can fold this one into #20010