Skip to content

Commit

Permalink
Post message to ServiceWorker if token has been changed
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Nov 14, 2024
1 parent 47d84c9 commit 2f082ec
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ const Main = () => {
}
}
};

registerServiceWorker();

useEffect(() => {
registerServiceWorker();
if ("serviceWorker" in navigator && navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage({
type: "TOKEN",
token: token,
});
}
}, [token]);
return <></>;
};
Expand Down

0 comments on commit 2f082ec

Please sign in to comment.