Reputation: 51
I want to use pusher.js in service worker for sending notification to user when the app(pwa) is closed. But I get below error in pusher.js:
window is not defined
Upvotes: 0
Views: 1877
Reputation: 51
I got the answer, in service worker you can not import pusher as below:
import Pusher from 'pusher-js';
Instead import as below:
importScripts("https://js.pusher.com/7.0/pusher.worker.min.js");
Or
import Pusher from 'pusher-js/worker';
Upvotes: 4