paricafe/packages/client/src/scripts/initialize-sw.ts
tamaina 4ecc42744c
enhance: Implement the toggle to (or not to) close push notifications when notifications or messages are read (#9219)
* create file

* wip

* fix

* wip

* tabun dekita

* ✌️

* implement subscribe push notification button to tutorial

* check-exists→show-registration

* add column sendReadMessage

* fix migration file

* sw api

* change PushNotificationService

* wip

* ✌️

* fix tutorial footer flex
2022-12-18 01:59:59 +09:00

13 lines
333 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,
});
});
}