从服务程序发送消息以在某些不支持BroadcastChannel的浏览器中做出反应

问题描述 投票:3回答:1

我能够从服务器成功获取推送通知并以此来更新react组件

    self.addEventListener('push', event => {
     const data = event.data.json();
     event.waitUntil(
       self.registration.showNotification(data.title, {
         body: data.body,
         image: './Flowster-icon-32.png'
      })
    );

     const channel = new BroadcastChannel('sw-messages');
     channel.postMessage(data);
   });

但是这些浏览器不支持sucs IE,Safari,donto支持BroadcastChannel,甚至client.postMessage也不受支持,我如何使其在那些浏览器中工作。感谢您的提前帮助。

reactjs web-services internet-explorer safari
1个回答
0
投票

由于BroadcastChannel doesn't support IE and safari browser,作为一种解决方法,我建议您可以尝试在IE或野生动物园浏览器中使用sysend.js

参考:How can I use the BroadcastChannel API or something similar in Safari 10+?

© www.soinside.com 2019 - 2024. All rights reserved.