javascript - Web/Desktop Notification API - force close all notifications upon refreshing the page -
i've been looking @ web notification api or desktop notification api. understand how it's constructed , number of attributes , events supports. notifications meant separated browser sot if browser minimized example notification can still displayed.
my question is, there way link notification actions on web page? in particular, want close notification dialogues upon refreshing page. how can make happen?
thanks in advance.
you don't mention service worker i'm going assume have 1 since need push , notifications apis.
when page loads, send message service worker instructing close notifications. can within worker this:
self.getnotifications().then(function(notifications){ notifications.foreach(function(notification){ notification.close() }) })
however can skip message service worker , page via service worker registration follows:
navigator.serviceworker.getregistration().then(function(registration){ registration.getnotifications().then(function(notifications){ notifications.foreach(function(notification){ notification.close() }) }) })
however, note getnotifications()
available chrome 44. before chrome 44, or in other browsers, don't believe there's way want.
Comments
Post a Comment