wails/v3/examples/badge
Zach Botterman ff6a333621
[v3] macOS Dock Service (#4451)
* dock service

* add docs and update comments

* remove unneeded doc imports

* update comment

* update comment

* update comment

* update changelog

* consolidate to dock service

* update examples + thread safety

* fix linux

* update docs

* thread safety

* Update v3/pkg/services/dock/dock_darwin.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-09-24 07:30:02 +00:00
..
build feat: Add Windows UAC configuration support to Wails v3 2025-06-12 22:23:09 +10:00
frontend [v3] macOS Dock Service (#4451) 2025-09-24 07:30:02 +00:00
main.go [v3] macOS Dock Service (#4451) 2025-09-24 07:30:02 +00:00
README.md update headers 2025-04-26 22:58:06 -07:00
Taskfile.yml add example, update docs, update changelog 2025-04-24 15:47:14 -07:00

Welcome to Your New Wails3 Project!

Now that you have your project set up, it's time to explore the basic badge features that Wails3 offers on macOS and Windows.

Exploring Badge Features

Creating the Service

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),
    },
})

Badge Operations

Setting a Badge

Set a badge on the application tile/dock icon:

Go

// Set a default badge
badgeService.SetBadge("")

// Set a numeric badge
badgeService.SetBadge("3")

// Set a text badge
badgeService.SetBadge("New")

JS

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")

Removing a Badge

Remove the badge from the application icon:

Go

badgeService.RemoveBadge()

JS

import {RemoveBadge} from "../bindings/github.com/wailsapp/wails/v3/pkg/services/badge/service";

RemoveBadge()