Navigator:clearAppBadge() 方法

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

Navigator 接口的 clearAppBadge() 方法通过将当前应用程序图标设置为 nothing 来清除当前应用程序图标上的徽章。nothing 表示当前没有设置徽章,并且徽章的状态为已清除

语法

js
clearAppBadge()

参数

无。

返回值

一个兑现为 undefinedPromise

异常

InvalidStateError DOMException

如果文档未完全激活,则抛出该异常。

SecurityError DOMException

如果调用被同源策略阻止,则抛出该异常。

NotAllowedError DOMException

如果 PermissionStatus.state 不是 granted,则抛出该异常。

示例

读取应用程序中的所有消息后,调用 clearAppBadge() 方法以清除徽章并删除通知。

js
navigator.clearAppBadge();

规范

Specification
Badging API
# clearappbadge-method

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
clearAppBadge

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

参见