diff options
author | Vitaly Takmazov | 2023-01-25 15:00:03 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-25 15:03:36 +0300 |
commit | 56080b328a158bd1301a86f45cc1194be95501d2 (patch) | |
tree | 57264cfce7a086e0aba16f43f14536e438403b0b /src/main/resources | |
parent | bc6c14d862746fe7da9f061d39ad69daa81f9eac (diff) |
Web Push: focus existing page on notification click
Diffstat (limited to 'src/main/resources')
-rw-r--r-- | src/main/resources/static/sw.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/resources/static/sw.js b/src/main/resources/static/sw.js index 48fe7787..055fcf64 100644 --- a/src/main/resources/static/sw.js +++ b/src/main/resources/static/sw.js @@ -22,8 +22,12 @@ sw.addEventListener('push', function(evt) { } }); sw.addEventListener('notificationclick', function(evt) { - evt.notification.close(); evt.waitUntil( - sw.clients.openWindow('https://juick.com/') + sw.clients.matchAll().then(function(clientList) { + if (clientList.length > 0) { + return clientList[0].focus(); + } + return sw.clients.openWindow('https://juick.com/'); + }) ); }); |