The setAppBadge()
method of the Navigator
interface sets a badge on the icon associated with this app. If a value is passed to the method, this will be set as the value of the badge. Otherwise the badge will display as a dot, or other indicator as defined by the platform.
On this page
Navigator: setAppBadge() method
Syntax
js
setAppBadge()
setAppBadge(contents)
Parameters
Return value
Exceptions
NotSupportedError
DOMException
-
The
Navigator
does not have a document that this action can be acted on.
Examples
In the example below an unread count is passed to setAppBadge()
. The badge should then display 30
.
js
const unread = 30;
navigator.setAppBadge(unread);
Specifications
Specification |
---|
Badging API # setappbadge-method |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
setAppBadge |
81Windows and macOS only. |
81Windows and macOS only. |
No | No | No |
17Badging is supported for web apps saved to the Dock in Safari 17 on the macOS Sonoma beta |
No | No | No | No | 16.4 | No |
See also
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/setAppBadge