WorkerNavigator: setAppBadge() method
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The setAppBadge()
method of the WorkerNavigator
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.
Syntax
setAppBadge()
setAppBadge(contents)
Parameters
Return value
Exceptions
InvalidStateError
DOMException
-
Thrown if the document is not fully active.
SecurityError
DOMException
-
Thrown if the call was blocked by the same-origin policy.
NotAllowedError
DOMException
-
Thrown if
PermissionStatus.state
is notgranted
.
Examples
In the example below an unread count is passed to setAppBadge()
. The badge should then display 30
.
const unread = 30;
navigator.setAppBadge(unread);
Specifications
No specification found
No specification data found for api.WorkerNavigator.setAppBadge
.
Check for problems with this page or contribute a missing spec_url
to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.
Browser compatibility
BCD tables only load in the browser