go-toast / toast

A go package for Windows 10 toast notifications
https://godoc.org/gopkg.in/toast.v1
MIT License
449 stars 65 forks source link

Option for persisting notifications in the Action Center #4

Closed Qxcl closed 8 years ago

Qxcl commented 8 years ago

Added field Persist bool to type Notification with accompanying logic in Notification.Push(). This determines if a toast should remain in the Action Center after it times out.

I think some people will find this option useful. 😺

jmshal commented 8 years ago

You might need to explain to me what's happening here, as in my testing, if the toast is not clicked, it shows up in the Action Center just fine. Sorry if I've missed something. And thanks for your contribution 😎

Qxcl commented 8 years ago

In my tests, notifications (at least those without any action buttons) will not remain in the Action Center after they disappear from the screen. Various posts on StackOverflow, MSDN, and personal blogs corroborate the existence of this issue with non-UWP and non-COM-registered apps.

Update: I have tested this in a sample app and oddly the notifications do stick in the Action Center, yet they did not in my win-toastd app. This appears to be one of those Heisenbugs.

Update2: After modifying the notification, it stopped persisting in the Action Center. My first test appeared to work at a glance by referencing a nonexistent Icon, but the notification was erroneously formed with the AppID as the Title and New notification as the Message.

Here is a sample program in which the notifications do not persist.

package main

import (
        toast "github.com/jacobmarshall/go-toast"
        "log"

)

func main() {
    notification := toast.Notification{
        AppID: "Test",
        Title: "My notification",
        Message: "Some message about how important something is...",
    }
    err := notification.Push()
    if err != nil {
        log.Fatalln(err)
    }
}
jmshal commented 8 years ago

I've just checked again, and these notifications seem to stay in the Action Center. May I ask, have you updated to Windows 10 Anniversary?

screenshot 2016-09-19 18 55 12
Qxcl commented 8 years ago

I have not updated to the Anniversary version. I'm Installing it now, and I'll let you know if that fixes everything. I thought I was all up to date, going by the Windows Update tool... 😞

jmshal commented 8 years ago

I have quite a few queued up now. So I'm pretty sure it's working as expected on Windows 10 anniversary update. Please feel free to close the PR if you're happy with your own tests.

Thanks again for looking into it though. I do appreciate the contribution 👍

screenshot 2016-09-19 20 28 11
Qxcl commented 8 years ago

After updating I can confirm they are not staying in the Action Center by default.

I've found the per-app switches in the "Notifications & actions" Settings. It appears they are set to not show in the Action Center by default.

Since I've found this solution, this change may not be so necessary.

off-by-default

jmshal commented 8 years ago

Mhmm, very interesting. "Show notifications in action center" is turned off by default for me too, however I see the notifications stack up in the Action Center regardless. So not too sure what this option is meant to do...

Thanks again.

Qxcl commented 8 years ago

Glad to contribute. Thanks for making this great package. 😄

abolinhas commented 1 year ago

+1 I can confirm that the notification is not persist in notification center on windows 10