From this article on MDN:
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
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
I’ve checked Chrome document but it doesn’t seem they have these functions.