Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在'上更新window.location;通知单击';在firebase的Angular应用程序中_Javascript_Angular_Firebase_Push Notification - Fatal编程技术网

Javascript 在'上更新window.location;通知单击';在firebase的Angular应用程序中

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

我的Angular应用程序(不是Angular SW!)中集成了firebase消息服务Worker

我有一个用于实现通知单击的eventListener,我想根据可用的选项卡执行不同的操作:

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”

我有没有办法集中注意力然后更新位置