[英]Unable to connect websocket into service-workers
即使應用程序瀏覽器窗口關閉,也希望實現后台推送通知,為了實現這一點,我使用的是service-worker和websocket,無法在服務工作文件中使用websocket。
//在serviceworker.js文件中
const webSocket = new WebSocket(`ws://local_host/socket`);
console.log(webSocket);
//出現以下錯誤
Uncaught DOMException: Failed to construct 'WebSocket': The
subprotocol '[object Object]' is invalid.
請幫忙解決這個問題。
Service Workers不支持Websockets。
推送通知應使用Web Push實現。 https://developers.google.com/web/fundamentals/push-notifications/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.