From this article on MDN:
The notifications.onClicked
has 3 functions which is:
browser.notifications.onClicked.addListener(callback)
browser.notifications.onClicked.removeListener(listener)
browser.notifications.onClicked.hasListener(listener)
I can understand addListener(callback)
pretty well, but removeListener(listener)
and hasListener(listener)
is kinda annoying to me. I totally have no idea what actually are. So here is some questions keep wondering in my mind:
- What is
listener
? Is it a promise object or id string of a notification? - Where do we get it (the
listener
)? It cannot a vague callback function right? - How to use these functions? The idea of remove functions is hard to understand to me? Why would we need to remove it? A thing that we try so hard to add it to an event? Moreover, isnât it will be get rid of event after the object destroyed? Notifications donât last forever right. And if we really need to change the content of notification, we can just use
browser.notifications.update()
.
Iâve checked Chrome document but it doesnât seem they have these functions.