Created
August 3, 2015 10:20
-
-
Save deanhume/c0d29d40e0c77dfbab8f to your computer and use it in GitHub Desktop.
Service Worker Notification Click
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('notificationclick', function(event) { | |
console.log('On notification click: ', event.notification.tag); | |
// Android doesn't close the notification when you click on it | |
// See: http://crbug.com/463146 | |
event.notification.close(); | |
// This looks to see if the current is already open and | |
// focuses if it is | |
event.waitUntil( | |
clients.matchAll({ | |
type: "window" | |
}) | |
.then(function(clientList) { | |
for (var i = 0; i < clientList.length; i++) { | |
var client = clientList[i]; | |
if (client.url == '/' && 'focus' in client) | |
return client.focus(); | |
} | |
if (clients.openWindow) { | |
return clients.openWindow('https://deanhume.github.io/typography'); | |
} | |
}) | |
); | |
}); |
@rajeevAgilehub Navigate to eslint config file and explore "env" section for more details.
"env": {
"clients": true,
"self": true.
Or otherwise, disable linting for this file only.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i m using Chrome,

i m developing in VS code Editor. I have installed Lint for error checking,
Lint is highlighting this as error, it is expecting it to be defined.