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.
// in serviceworker.js file
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.
Push notifications should be implemented using Web Push. https://developers.google.com/web/fundamentals/push-notifications/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.