v3/examples/badge/README.md
Now that you have your project set up, it's time to explore the basic badge features that Wails3 offers on macOS and Windows.
First, initialize the badge service:
import "github.com/wailsapp/wails/v3/pkg/application"
import "github.com/wailsapp/wails/v3/pkg/services/badge"
// Create a new badge service
badgeService := badge.New()
// Register the service with the application
app := application.New(application.Options{
Services: []application.Service{
application.NewService(badgeService),
},
})
Set a badge on the application tile/dock icon:
// Set a default badge
badgeService.SetBadge("")
// Set a numeric badge
badgeService.SetBadge("3")
// Set a text badge
badgeService.SetBadge("New")
import {SetBadge} from "../bindings/github.com/wailsapp/wails/v3/pkg/services/badge/service";
// Set a default badge
SetBadge("")
// Set a numeric badge
SetBadge("3")
// Set a text badge
SetBadge("New")
Remove the badge from the application icon:
badgeService.RemoveBadge()
import {RemoveBadge} from "../bindings/github.com/wailsapp/wails/v3/pkg/services/badge/service";
RemoveBadge()