jormungandr-bite/packages/client/src/scripts/initialize-sw.ts
ThatOneCalculator 3e7d64ac4b feat: push notifs button
Co-authored-by: Tamania <tamaina@hotmail.co.jp>
2023-04-03 20:36:59 -07:00

13 lines
335 B
TypeScript

import { lang } from "@/config";
export async function initializeSw() {
if (!("serviceWorker" in navigator)) return;
navigator.serviceWorker.register("/sw.js", { scope: "/", type: "classic" });
navigator.serviceWorker.ready.then((registration) => {
registration.active?.postMessage({
msg: "initialize",
lang,
});
});
}