Angular Firebase云消息fcm_选项。单击时未打开链接url

Angular Firebase云消息fcm_选项。单击时未打开链接url,angular,firebase,firebase-cloud-messaging,Angular,Firebase,Firebase Cloud Messaging,我正在向web应用程序发送fcm消息,我可以在后台接收消息,但当我单击“警报”时,它不会在浏览器中打开URL,一切正常,只是链接不起作用 这是我要发的信息,请帮忙 { "notification": { "title": "Hello World", "body": "Enjoy your coffee" }, "webpush": { "fcm_options": { "link": "https://weather.com/en-CA/weather/tod

我正在向web应用程序发送fcm消息,我可以在后台接收消息,但当我单击“警报”时,它不会在浏览器中打开URL,一切正常,只是链接不起作用

这是我要发的信息,请帮忙

{
"notification": {
"title": "Hello World",
"body": "Enjoy your coffee"
},

 "webpush": {

      "fcm_options": {
        "link": "https://weather.com/en-CA/weather/today/l/CAON4756:"
      }
    }

"to" : ""
}
我的firebase-messaging-sw.js文件

importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-messaging.js');



firebase.initializeApp({
  'messagingSenderId': ''
});

const messaging = firebase.messaging();





只能打开与注册的
服务人员具有相同
主机的
链接

在您的信息中,
主机
weather.com
,它不会感知您注册的
服务人员的
主机

我打开第三方网站的解决方案是设置
url参数

解决方案
somepage

let urlToOpen = getQueryVariable(window.location.search.substring(1), "url")
if (urlToOpen) {
    window.open(urlToOpen, "_self")
}

function getQueryVariable(query, variable) {
    const vars = query.split("&")
    for (let i = 0; i < vars.length; i++) {
        const pair = vars[i].split("=")
        if (pair[0] === variable) {
            return pair[1]
        }
    }
    return false
}

我找到了这篇文章,它有帮助,但仍然不确定为什么fcm_选项链接url不起作用,因为
只能打开与注册服务人员具有相同主机的链接。
是关键。谢谢但是,如果选项卡处于打开状态,它仍然无法路由到链接中的正确页面。如果我关闭标签。它起作用了。
{
    "notification": {
        "title": "Hello World",
            "body": "Enjoy your coffee"
    },

    "webpush": {
        "fcm_options": {
            "link": "url2somepage" + "?url=" + "https://weather.com/en-CA/weather/today/l/CAON4756:"
            // replace the 'url2somepage' with the url to a page which contains the previous js
        }
    }

    "to" : ""
}