- From: Ayke <notifications@github.com>
- Date: Mon, 13 Jul 2015 04:25:12 -0700
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
- Message-ID: <slightlyoff/ServiceWorker/issues/720@github.com>
When using a [web application manifest](http://w3c.github.io/manifest/) together with a service worker, this can happen: 1. The user opens a web application and installs it as application (using the manifest), for example in Chrome for Android's "Add to Homescreen". 2. The user uses the app as if it were a native application, for example when using "display"="standalone" in the application manifest. 3. The application gets a push notification. When clicking the notification, this code is executed (from [MDN](https://developer.mozilla.org/en-US/docs/Web/API/WindowClient/focus): ```javascript self.addEventListener('notificationclick', function(event) { console.log('On notification click: ', event.notification.tag); 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('/'); })); }); ``` 4. If only the web application is open, that is opened. If there is no client, a new tab/window will be opened in the browser, not the application saved to the homescreen as expected. Maybe this is an implementation issue, but I think there should be a way for a service worker to specify how the window should be opened, or it should always be opened as an app if it is installed. --- Reply to this email directly or view it on GitHub: https://github.com/slightlyoff/ServiceWorker/issues/720
Received on Monday, 13 July 2015 11:25:45 UTC