addeventlistener('notificationclick', event =>{
event.waituntil(async function(){
const allclients = await clients.machall({
includeuncontrolled: true
});
let chatclient;
for (const client of allclients){
const url = new url (client.url);
if (url.pathname =='/chat/'){
client.focus();
chatclient = client;
break;
}
}
if (!chatclient){
chatclient = await clients.openwindow('/chat/');
}
chatclient.postmessage("new chat messages!");
}());
});
The Clients interface provides access to Client objects. Access it via self.clients within a service worker.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.