Javascript 在'上更新window.location;通知单击';在firebase的Angular应用程序中
我的Angular应用程序(不是Angular SW!)中集成了firebase消息服务Worker 我有一个用于实现通知单击的eventListener,我想根据可用的选项卡执行不同的操作:Javascript 在'上更新window.location;通知单击';在firebase的Angular应用程序中,javascript,angular,firebase,push-notification,Javascript,Angular,Firebase,Push Notification,我的Angular应用程序(不是Angular SW!)中集成了firebase消息服务Worker 我有一个用于实现通知单击的eventListener,我想根据可用的选项卡执行不同的操作: self.addEventListener('notificationclick', (event) => { ... clients.matchAll({type: "window", includeUncontrolled: true}).then((wind
self.addEventListener('notificationclick', (event) => {
...
clients.matchAll({type: "window", includeUncontrolled: true}).then((windows) => {
windows.forEach((win) => {
if (win.url.toString().endsWith("/appointments/" + singleDateAppointmentId)){
console.log('ENDS WITH SDA');
return win.focus();
}else if(win.url.toString().endsWith("/appointments")){
console.log('ENDS WITH APPOINTMENTS');
win.focus();
return window.location.replace("/appointments/" + singleDateAppointmentId);
}else{
console.log('NONE FOUND, OPENING NEW TAB');
return clients.openWindow("/appointments/" + singleDateAppointmentId);
}
})
所以案例1和案例3是开箱即用的,但我无法更新聚焦窗口的位置,它说
firebase messaging sw.js:119未捕获(承诺中)引用错误:未定义窗口
将其更改为win.location.replace(“/appoints/”+singleDateAppointmentId)代码>也不起作用,因为“win.location*未定义:
未捕获(承诺中)TypeError:无法读取未定义的属性“replace”
我有没有办法集中注意力然后更新位置