diff --git a/src/pages/settings/panes/Notifications.tsx b/src/pages/settings/panes/Notifications.tsx index 921beb7b..d2dcdee9 100644 --- a/src/pages/settings/panes/Notifications.tsx +++ b/src/pages/settings/panes/Notifications.tsx @@ -61,57 +61,59 @@ export const Notifications = observer(() => { settings.set("notifications:desktop", desktopEnabled); }} /> - - } - description={ - - } - onChange={async (pushEnabled) => { - try { - const reg = - await navigator.serviceWorker?.getRegistration(); - if (reg) { - if (pushEnabled) { - const sub = await reg.pushManager.subscribe( - { - userVisibleOnly: true, - applicationServerKey: - urlBase64ToUint8Array( - client.configuration!.vapid, - ), - }, - ); - - // tell the server we just subscribed - const json = sub.toJSON(); - if (json.keys) { - client.api.post("/push/subscribe", { - endpoint: sub.endpoint, - ...(json.keys as { - p256dh: string; - auth: string; - }), - }); - setPushEnabled(true); - } - } else { - const sub = - await reg.pushManager.getSubscription(); - sub?.unsubscribe(); - setPushEnabled(false); - - client.api.post("/push/unsubscribe"); - } - } - } catch (err) { - console.error("Failed to enable push!", err); + {!window.native && ( + } - }} - /> + description={ + + } + onChange={async (pushEnabled) => { + try { + const reg = + await navigator.serviceWorker?.getRegistration(); + if (reg) { + if (pushEnabled) { + const sub = + await reg.pushManager.subscribe({ + userVisibleOnly: true, + applicationServerKey: + urlBase64ToUint8Array( + client.configuration! + .vapid, + ), + }); + + // tell the server we just subscribed + const json = sub.toJSON(); + if (json.keys) { + client.api.post("/push/subscribe", { + endpoint: sub.endpoint, + ...(json.keys as { + p256dh: string; + auth: string; + }), + }); + setPushEnabled(true); + } + } else { + const sub = + await reg.pushManager.getSubscription(); + sub?.unsubscribe(); + setPushEnabled(false); + + client.api.post("/push/unsubscribe"); + } + } + } catch (err) { + console.error("Failed to enable push!", err); + } + }} + /> + )}