notifications.onButtonClicked

當用戶點選通知的按鈕時觸發。

語法

js
browser.notifications.onButtonClicked.addListener(listener)
browser.notifications.onButtonClicked.removeListener(listener)
browser.notifications.onButtonClicked.hasListener(listener)

事件有三個函式

addListener(listener)

向此事件新增監聽器。

removeListener(listener)

停止監聽此事件。listener 引數是要移除的監聽器。

hasListener(listener)

檢查 listener 是否已為此事件註冊。如果正在監聽,則返回 true,否則返回 false

addListener 語法

引數

監聽器

此事件發生時呼叫的函式。該函式會傳遞以下引數:

notificationId

string。已點選按鈕的通知的 ID。

buttonIndex

integer。已點選按鈕的從零開始的索引。

瀏覽器相容性

注意: 此 API 基於 Chromium 的 chrome.notifications API。