Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. WorkerNavigator
  4. setAppBadge()

WorkerNavigator: setAppBadge() method

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

ThesetAppBadge() method of theWorkerNavigator 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

js
setAppBadge()setAppBadge(contents)

Parameters

contentsOptional

Anumber which will be used as the value of the badge. Ifcontents is0 then the badge will be set tonothing, indicating a cleared badge.

Return value

APromise that resolves withundefined.

Exceptions

InvalidStateErrorDOMException

Thrown if the document is not fully active.

SecurityErrorDOMException

Thrown if the call was blocked by thesame-origin policy.

NotAllowedErrorDOMException

Thrown ifPermissionStatus.state is notgranted.

Examples

In the example below an unread count is passed tosetAppBadge(). The badge should then display30.

js
const unread = 30;navigator.setAppBadge(unread);

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp