0
私は 'notificationclick'イベントを追加したWebワーカーがいます。 同じタブでurlに移動し、新しいタブを開いていないとします。Webサービスワーカー通知同じページのURLをクリックして開く
どのようにこれを行うには手がかり?
self.addEventListener('notificationclick', function (event) {
const id = event.notification.data.id;
let path = 'http://' + event.target.location.host;
if (event.notification.data.type === 'invite')
path += '/invite/' + id;
else
path += '/notification/' + id;
event.notification.close();
const promiseChain = clients.matchAll({
type: 'window',
includeUncontrolled: true
})
.then((windowClients) => {
let matchingClient = null;
for (let i = 0; i < windowClients.length; i++) {
const windowClient = windowClients[i];
if (windowClient.url === path) {
matchingClient = windowClient;
break;
}
}
if (matchingClient) {
return matchingClient.focus();
} else {
return clients.openWindow(path);
}
});
event.waitUntil(promiseChain);
});
あなたがこの問題を解決しましたか? –
Nope。それについてインターネットには何もありません:( – MusicGindos