fix input id

This commit is contained in:
Zach Botterman 2025-02-24 16:47:19 -08:00
commit be716fc0ee
3 changed files with 15 additions and 4 deletions

View file

@ -3,7 +3,7 @@ module github.com/wailsapp/wails/v3
go 1.24.0
require (
git.sr.ht/~jackmordaunt/go-toast v1.1.2
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3
github.com/Masterminds/semver v1.5.0
github.com/adrg/xdg v0.5.3
github.com/atterpac/refresh v0.8.4

View file

@ -8,8 +8,8 @@ atomicgo.dev/schedule v0.1.0 h1:nTthAbhZS5YZmgYbb2+DH8uQIZcTlIrd4eYr3UQxEjs=
atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU=
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
git.sr.ht/~jackmordaunt/go-toast v1.1.2 h1:/yrfI55LRt1M7H1vkaw+NaH1+L1CDxrqDltwm5euVuE=
git.sr.ht/~jackmordaunt/go-toast v1.1.2/go.mod h1:jA4OqHKTQ4AFBdwrSnwnskUIIS3HYzlJSgdzCKqfavo=
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 h1:N3IGoHHp9pb6mj1cbXbuaSXV/UMKwmbKLf53nQmtqMA=
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3/go.mod h1:QtOLZGz8olr4qH2vWK0QH0w0O4T9fEIjMuWpKUsH7nc=
github.com/AlekSi/pointer v1.2.0 h1:glcy/gc4h8HnG2Z3ZECSzZ1IX1x2JxRVuDzaJwQE0+w=
github.com/AlekSi/pointer v1.2.0/go.mod h1:gZGfd3dpW4vEc/UlyfKKi1roIqcCgwOIvb0tSNSBle0=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=

View file

@ -11,7 +11,7 @@ import (
"strings"
"sync"
"git.sr.ht/~jackmordaunt/go-toast"
"git.sr.ht/~jackmordaunt/go-toast/v2"
"github.com/wailsapp/wails/v3/pkg/application"
"golang.org/x/sys/windows/registry"
)
@ -36,7 +36,15 @@ func (ns *Service) ServiceName() string {
// ServiceStartup is called when the service is loaded
// Sets an activation callback to emit an event when notifications are interacted with.
func (ns *Service) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
toast.SetAppData(toast.AppData{
AppID: "Notifications",
GUID: "{8F2E1A3D-C497-42B6-9E5D-72F8A169B051}",
IconPath: "C:\\Users\\Zach\\Development\\notifications_demo\\build\\appicon.ico",
ActivationExe: "C:\\Users\\Zach\\Development\\notifications_demo\\bin\\Notifications.exe",
})
toast.SetActivationCallback(func(args string, data []toast.UserData) {
println("HERE!")
actionIdentifier, userInfo := parseNotificationResponse(args)
response := NotificationResponse{
Name: "notification",
@ -94,6 +102,7 @@ func (ns *Service) SendNotification(options NotificationOptions) error {
Title: options.Title,
Body: options.Body,
ActivationArguments: defaultAction,
Audio: toast.IM,
}
if options.Data != nil {
@ -124,6 +133,7 @@ func (ns *Service) SendNotificationWithActions(options NotificationOptions) erro
Title: options.Title,
Body: options.Body,
ActivationArguments: defaultAction,
Audio: toast.IM,
}
for _, action := range nCategory.Actions {
@ -143,6 +153,7 @@ func (ns *Service) SendNotificationWithActions(options NotificationOptions) erro
n.Actions = append(n.Actions, toast.Action{
Content: nCategory.ReplyButtonTitle,
Arguments: "TEXT_REPLY",
InputID: "userText",
})
}