diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -41,6 +41,7 @@ import UpdateModalHandler from './modals/update-modal.react.js'; import SettingsSwitcher from './navigation-panels/settings-switcher.react.js'; import Topbar from './navigation-panels/topbar.react.js'; +import { PushNotificationsHandler } from './push-notif/push-notifs-handler.js'; import { updateNavInfoActionType } from './redux/action-types.js'; import DeviceIDUpdater from './redux/device-id-updater.js'; import DisconnectedBarVisibilityHandler from './redux/disconnected-bar-visibility-handler.js'; @@ -163,6 +164,7 @@ + {content} {this.props.modals} diff --git a/web/push-notif/push-notifs-handler.js b/web/push-notif/push-notifs-handler.js new file mode 100644 --- /dev/null +++ b/web/push-notif/push-notifs-handler.js @@ -0,0 +1,21 @@ +// @flow + +import * as React from 'react'; + +import electron from '../electron.js'; + +function PushNotificationsHandler(): React.Node { + React.useEffect(() => { + (async () => { + if (!navigator.serviceWorker || electron) { + return; + } + + await navigator.serviceWorker.register('/worker/notif', { scope: '/' }); + })(); + }, []); + + return null; +} + +export { PushNotificationsHandler };