Tdesktop: Notification is removed from Windows Action center

Created on 5 Aug 2016  路  22Comments  路  Source: telegramdesktop/tdesktop

Steps to reproduce

  1. Receive a new message
  2. Open the Action center to view the notification
  3. Close the Action center
  4. Open the Action center again

    Expected behaviour

I should see the notification of the new message.

Actual behaviour

The notification is gone.

Configuration

Operating system: Windows 10.0.14393

Version of Telegram Desktop: 0.10

bug stale windows

Most helpful comment

Hey @john-preston, this is Andrew from Microsoft, I work on the toast notifications team and saw this thread.

We just made some massive improvements to the Win32 toast notification docs, including making it way easier to implement the COM server!

Additionally, I noticed you were also having issues with calling Hide() on notifications... instead you should use the toast history, and then call either Clear() to clear all toasts, or call Remove() to remove a specific toast. Would love to talk with you more on that!

Please reach out to me, my email address is my GitHub username @microsoft.com. We'd love to work with you to help make Telegram integrate better with Windows 10!

All 22 comments

@auchri Windows removes them as soon as they're hidden =(

So..why do you hide them? :worried:

Windows hides them =(

But notifications from other apps stay there until I manually remove them. (or perform an action in the app)

Maybe you should take a look at the sample app and compare it to your code...

For me the notification disappears from the Action Center without any interaction, it pops up, the number of unread notifications on the Action Center icon increases, but when the pop up closes the number on the icon decreases instantly and when I open the Action Center the notification isn't there.

I'm on Windows 10 Anniversary Update (1607)

I just found this:

Win32 apps need to set up a COM server in order to have toasts persisted in Action Center: http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/10/15/quickstart-handling-toast-activations-from-win32-apps-in-windows-10.aspx

@john-preston Did you implement a COM server?

@auchri No. And I would rather not to 馃槶

Native notifications have a tendency to cause Telegram to crash for me with the Windows 10 Anniversary Update. Might be time to look into how this can be improved. It sounds like it's possible to set notifications to persist while the application is running without all that COM nonsense, which should be sufficient for most people.

You can workaround this problem by going into Notification Settings -> Telegram and enabling Show in Action Center. The notifications will persist in the Action Center, but will be greyed out and unclickable, and doesn't go away until you clear it manually. It isn't the best, but it works partially.

Hey @john-preston, this is Andrew from Microsoft, I work on the toast notifications team and saw this thread.

We just made some massive improvements to the Win32 toast notification docs, including making it way easier to implement the COM server!

Additionally, I noticed you were also having issues with calling Hide() on notifications... instead you should use the toast history, and then call either Clear() to clear all toasts, or call Remove() to remove a specific toast. Would love to talk with you more on that!

Please reach out to me, my email address is my GitHub username @microsoft.com. We'd love to work with you to help make Telegram integrate better with Windows 10!

@anbare Hi! Thanks for reaching out. Will the same build work in Windows XP as well? Current version is one binary for all versions from XP to 10.

Windows XP and Windows 7 didn't have toast notifications, so you would want to check which OS you're on before trying to call toast APIs on those versions of Windows. I imagine you already have some code that does that since you already show notifications?

Windows 8 introduced toasts, but Action Center wasn't added till Windows 10. Additionally, interactive toasts using the new ToastGeneric XML wasn't added till Windows 10. So the code sample today wouldn't work for Windows 8 devices (you'd similarly have to check the OS and use older code for Windows 8 toasts).

Do you have a goal to show native toast notifications on Windows 8 devices? Or is showing them only on Windows 10 devices acceptable, and use the custom drawn UI notifications for Windows 8?

@anbare Currently Windows 8 toasts are supported, I think they can be left unchanged if the changes are huge for the new approach.

Sounds like a good plan. I'll research on Monday how you can use this new Windows 10 code while still supporting Windows 8 since that'd be worthy to document for everyone, but feel free to look at the docs yourself too!

@john-preston I researched this and the docs will be updated in a couple days with info on handling older versions!

The key differences are...

  • Windows 10 uses the COM activator
  • Windows 10 uses ToastGeneric XML rather than the legacy XML templates

So, you'll want to follow all of the steps in the docs except...

  • When you're calling the Register methods in your app's initialization, you'll want to only do that if running on Windows 10.
  • When you're constructing your XML, if running on Windows 10, construct ToastGeneric XML, otherwise use your current XML

For sending the toast, you shouldn't need to call the DesktopNotificationManagerCompat method to send the toast, you should be able to use your existing code, since you should already be passing in your AUMID when creating the ToastNotifier. But you can fork that code if you'd like too.

Additionally, in Windows 10, do NOT wire up the Activated event on the ToastNotification object. Activation will be performed via the COM activator. In Windows 8, you'll have to continue using that Activated event on the ToastNotification though.

Here's some more info...

Handling older versions of Windows

If you support Windows 8.1 or lower, you'll want to check at runtime whether you're running on Windows 10 before calling any DesktopNotificationManagerCompat APIs or sending any ToastGeneric toasts.

Windows 8 introduced toast notifications, but used the legacy toast templates, like ToastText01. Activation was handled by the in-memory Activated event on the ToastNotification class since toasts were only brief popups that weren't persisted. Windows 10 introduced interactive ToastGeneric toasts, and also introduced Action Center where notifications are persisted for multiple days. The introduction of Action Center required the introduction of a COM activator, so that your toast can be activated days after you created it.

| OS | ToastGeneric | COM activator | Legacy toast templates |
| -- | ------------ | ------------- | ---------------------- |
| Windows 10 | Supported | Supported | Supported (but won't activate COM server) |
| Windows 8.1 / 8 | N/A | N/A | Supported |
| Windows 7 and lower | N/A | N/A | N/A |

To check if you're running on Windows 10, include the <VersionHelpers.h> header and check the IsWindows10OrGreater method. If this returns true, continue calling all the methods described in this documentation!

#include <VersionHelpers.h>

if (IsWindows10OrGreater())
{
    // Running Windows 10, continue with sending Windows 10 toasts!
}

Additionally, I noticed a code typo in the docs where WrlFinal is used on the COM activator class declaration. WrlFinal should be listed right after WrlSealed, not at the very end like it is today, otherwise you'll get a compile error when building release version.

The docs will be updated in a couple days, but here's the correct code snippet.

// The UUID CLSID must be unique to your app. Create a new GUID if copying this code.
class DECLSPEC_UUID("replaced-with-your-guid-C173E6ADF0C3") NotificationActivator WrlSealed WrlFinal
    : public RuntimeClass<RuntimeClassFlags<ClassicCom>, INotificationActivationCallback>
{
public:
    virtual HRESULT STDMETHODCALLTYPE Activate(
        _In_ LPCWSTR appUserModelId,
        _In_ LPCWSTR invokedArgs,
        _In_reads_(dataCount) const NOTIFICATION_USER_INPUT_DATA* data,
        ULONG dataCount) override
    {
        // TODO: Handle activation
    }
};

// Flag class as COM creatable
CoCreatableClass(NotificationActivator);

Any update on this issue?

@andrewleader

The same thing happened to me when I was trying to build other win32 bridge applications. After much research and searching, I found this place..

I've followed the https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/send-local-toast-desktop-cpp-wrl,step by step

Win32 bridge

If I package it as appx.
It work perfectly normal in 1903 and 1909.
But it won't work on 1607(14393),1703(15063)

  1. The text where the appname should be displayed, display AMUID incorectly
  1. Unable to keep in action center, auto dissmiss when timeout.

Standard destop app

If not packaged as appx, but the standard desktop application, it works in all os (from 1607 to 1909)

@grapehunter I don't think Desktop Bridge was supported back in 1607 and 1703? The MSIX docs say support started in 1709.

@grapehunter I don't think Desktop Bridge was supported back in 1607 and 1703? The MSIX docs say support started in 1709.

I got it. Thank you very much for your reply.
It seems that I used an deprecated tool/doc here. https://github.com/felixrieseberg/electron-windows-store

Hey there!

This issue will be automatically closed in 7 days if there would be no activity. We therefore assume that the user has lost interest or resolved the problem on their own.

Don't worry though; if this is an error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

beppe9000 picture beppe9000  路  3Comments

Yanrishatum picture Yanrishatum  路  3Comments

Justinzobel picture Justinzobel  路  3Comments

hosseinab picture hosseinab  路  3Comments

TotalKrill picture TotalKrill  路  3Comments