This commit is contained in:
@@ -104,43 +104,50 @@ self.addEventListener('notificationclick', (event) => {
|
||||
console.log('focus')
|
||||
|
||||
return Promise.all([
|
||||
client.focus(),
|
||||
client.postMessage({
|
||||
type: 'notificationClick',
|
||||
tag: event.notification.tag,
|
||||
payload: event.notification.payload,
|
||||
matchUrl: true,
|
||||
}),
|
||||
client.focus(),
|
||||
])
|
||||
}
|
||||
}
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
if (!clients.openWindow) {
|
||||
throw new Error('clients.openWindow not available')
|
||||
}
|
||||
return clients.openWindow(urlToOpen).then((newClient) => {
|
||||
if (!newClient) {
|
||||
throw new Error('new window not opened')
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
console.debug('Error', error)
|
||||
for (const client of clientList) {
|
||||
return Promise.all([
|
||||
if (clients.openWindow) {
|
||||
console.log('open new window', urlToOpen)
|
||||
|
||||
return clients.openWindow(urlToOpen).then((client) => {
|
||||
if (!client) {
|
||||
console.log('new window not opened')
|
||||
for (const client of clientList) {
|
||||
client.postMessage({
|
||||
type: 'notificationClick',
|
||||
url: urlToOpen,
|
||||
tag: event.notification.tag,
|
||||
payload: event.notification.payload,
|
||||
matchUrl: false,
|
||||
msg: 'clients.openWindow not available',
|
||||
}),
|
||||
client.focus(),
|
||||
])
|
||||
msg: 'new window not opened',
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('clients.openWindow not available')
|
||||
|
||||
for (const client of clientList) {
|
||||
client.postMessage({
|
||||
type: 'notificationClick',
|
||||
url: urlToOpen,
|
||||
tag: event.notification.tag,
|
||||
payload: event.notification.payload,
|
||||
matchUrl: false,
|
||||
msg: 'clients.openWindow not available',
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
.catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user