[英]Unable to connect websocket into service-workers
Wants to implement background push notififications even when the application browser window is closed, to achieve this i am using service-worker and websocket,unable to use websocket in service worker file. 即使应用程序浏览器窗口关闭,也希望实现后台推送通知,为了实现这一点,我使用的是service-worker和websocket,无法在服务工作文件中使用websocket。
// in serviceworker.js file //在serviceworker.js文件中
const webSocket = new WebSocket(`ws://local_host/socket`);
console.log(webSocket);
//Got following error //出现以下错误
Uncaught DOMException: Failed to construct 'WebSocket': The
subprotocol '[object Object]' is invalid.
Please help regarding this issue. 请帮忙解决这个问题。
Websockets are not supported in Service Workers. Service Workers不支持Websockets。
Push notifications should be implemented using Web Push. 推送通知应使用Web Push实现。 https://developers.google.com/web/fundamentals/push-notifications/
https://developers.google.com/web/fundamentals/push-notifications/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.