serviceworkers focus tab: clients is empty on notificationclick

后端 未结 2 790
渐次进展
渐次进展 2020-12-17 09:59

I have a common serviceworker escenario, where I want catch a notification click and focus the tab where the notification has come from. However, clients variable is always

2条回答
  •  失恋的感觉
    2020-12-17 10:22

    Try making the service worker immediately claim the page. E.g.:

    self.addEventListener('install', event => event.waitUntil(self.skipWaiting()));
    
    self.addEventListener('activate', event => event.waitUntil(self.clients.claim()));
    

    For a more complex example, see https://serviceworke.rs/immediate-claim.html.

提交回复
热议问题