-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathnotify_windows.go
More file actions
36 lines (32 loc) · 897 Bytes
/
notify_windows.go
File metadata and controls
36 lines (32 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package notify
import (
"github.com/ActiveState/cli/internal/assets"
"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/fileutils"
"github.com/ActiveState/cli/internal/locale"
"gopkg.in/toast.v1"
)
func Send(title, message, actionName, actionLink string) error {
iconBytes, err := assets.ReadFile("icon.png")
if err != nil {
return errs.Wrap(err, "Could not read asset")
}
iconFile, err := fileutils.WriteTempFile("*.png", iconBytes)
if err != nil {
return errs.Wrap(err, "Could not write temp file")
}
notification := toast.Notification{
AppID: locale.T("org_name"),
Title: title,
Icon: iconFile,
Message: message,
Actions: []toast.Action{
{"protocol", actionName, actionLink},
},
Duration: toast.Long,
}
if err := notification.Push(); err != nil {
return errs.Wrap(err, "Could not send notification")
}
return nil
}