Navigator:clearAppBadge() 方法

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

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

语法

js
clearAppBadge()

参数

无。

返回值

一个兑现为 undefinedPromise

异常

InvalidStateError DOMException

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

SecurityError DOMException

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

NotAllowedError DOMException

如果 PermissionStatus.state (en-US) 不是 granted,则抛出该异常。

示例

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

js
navigator.clearAppBadge();

规范

Specification
Badging API
# clearappbadge-method

浏览器兼容性

BCD tables only load in the browser

参见