Try focus first, then postMessage

This commit is contained in:
Lim Chee Aun 2023-10-19 17:45:27 +08:00
parent e9075906f8
commit c9545cdc34

View file

@ -179,12 +179,12 @@ self.addEventListener('notificationclick', (event) => {
console.log('NOTIFICATION CLICK navigate', url); console.log('NOTIFICATION CLICK navigate', url);
if (bestClient) { if (bestClient) {
console.log('NOTIFICATION CLICK postMessage', bestClient); console.log('NOTIFICATION CLICK postMessage', bestClient);
bestClient.focus();
bestClient.postMessage?.({ bestClient.postMessage?.({
type: 'notification', type: 'notification',
id: tag, id: tag,
accessToken: access_token, accessToken: access_token,
}); });
bestClient.focus();
} else { } else {
console.log('NOTIFICATION CLICK openWindow', url); console.log('NOTIFICATION CLICK openWindow', url);
await self.clients.openWindow(url); await self.clients.openWindow(url);