microsoft / microsoft/WindowsAppSDK

Taskbar badge does not show until the app window closed

Open
#3,928 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Notifications
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### Describe the bug

I am using `Windows.UI.Notification.BadgeUpdateManager` api to add a badge to taskbar icon for a winui3 app, the badge does not appear in the taskbar icon until the window is closed. And it will disappear after it launches. In short, it seems that a winui3 app cannot show the badge when the app window is running.

**For UWP app however, badge will appear as soon as the function is called.**

### Steps to reproduce the bug

1. Use following code
```cpp
inline auto MakeBadgeNotification(wchar_t const* glyph)
{
auto xml = winrt::Windows::UI::Notifications::BadgeUpdateManager::GetTemplateContent(
winrt::Windows::UI::Notifications::BadgeTemplateType::BadgeGlyph
);
xml.SelectSingleNode(L"/badge")
.as()
.SetAttribute(L"value", glyph);
return winrt::Windows::UI::Notifications::BadgeNotification{ xml };
}

inline auto MakeBadgeNotification(int value)
{
auto xml = winrt::Windows::UI::Notifications::BadgeUpdateManager::GetTemplateContent(
winrt::Windows::UI::Notifications::BadgeTemplateType::BadgeNumber
);
xml.SelectSingleNode(L"/badge")
.as()
.SetAttribute(L"value", winrt::to_hstring(value));
return winrt::Windows::UI::Notifications::BadgeNotification{ xml };
}

winrt::Windows::UI::Notifications::BadgeUpdateManager::CreateBadgeUpdaterForApplication().Update(MakeBadgeNotification(1)); //number badge
winrt::Windows::UI::Notifications::BadgeUpdateManager::CreateBadgeUpdaterForApplication().Update(MakeBadgeNotification(L"alert")); //glyph badge
```
2. Badge only appears in start menu, not in taskbar
3. Close the app, the taskbar pinned icon now has badge.

### Expected behavior

_No response_

### Screenshots

This is Winui3 app
![image](https://github.com/microsoft/WindowsAppSDK/assets/42881734/efb65ba5-0767-4cfb-a4e4-416c015a1c84)

After closing the window:
![image](https://github.com/microsoft/WindowsAppSDK/assets/42881734/e0bc511d-0bc5-4663-966a-42505d8dad72)

This is UWP app
![image](https://github.com/microsoft/WindowsAppSDK/assets/42881734/287d5249-709a-41a2-b370-94fa3a617047)

### NuGet package version

Windows App SDK 1.4.2: 1.4.231008000

### Packaging type

Packaged (MSIX)

### Windows version

Windows 10 version 1809 (17763, October 2018 Update)

### IDE

_No response_

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the packaged WinUI 3 behavior with the shown MakeBadgeNotification code and BadgeUpdateManager APIs on the reported Windows and Windows App SDK versions. Compare taskbar and Start menu behavior with the UWP case, then trace the Windows App SDK notification integration to identify where live taskbar updates diverge. Done means badges appear while the WinUI 3 window is running and do not disappear after launch.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.