title: Push web api, notificationclick, how to open desktop client instead opening a new browser client
body: <p>Talking about Service Workers, when a push notifications arrives, we can handle the user click in those notifications, </p>
  
  <p>for example, opening the url in a new tab of the browser if not already opened. 
  But if we had a desktop web app (added to HomeScreen), how can we open it? </p>
  
  <pre><code>self.addEventListener('notificationclick', function(event) {
      console.log('Notification click: tag ', event.notification.tag);
      event.notification.close();
      var url = 'https://youtu.be/gYMkEMCHtJ4';
      event.waitUntil(
          clients.matchAll({
              type: 'window'
          })
          .then(function(windowClients) {
              for (var i = 0; i &lt; windowClients.length; i++) {
                  var client = windowClients[i];
                  if (client.url === url &amp;&amp; 'focus' in client) {
                      return client.focus();
                  }
              }
              if (clients.openWindow) {
                  return clients.openWindow(url);
              }
          })
      );
  });
  </code></pre>
  
  <p>In this code, clients.openWindow(url); will always open the app in the browser.</p>