From 06e2fabe819c1e84f5c83fa8124fe5a31fdc29f2 Mon Sep 17 00:00:00 2001 From: metacryst Date: Thu, 26 Mar 2026 05:56:14 -0500 Subject: [PATCH] push notifications working --- src/env.js | 3 --- src/index.js | 8 +++++--- 2 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 src/env.js diff --git a/src/env.js b/src/env.js deleted file mode 100644 index f59515e..0000000 --- a/src/env.js +++ /dev/null @@ -1,3 +0,0 @@ -class env { - BASE_URL = "https://parchment.page" -} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 40d6207..e85b3de 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ import "./Home/Home.js" import "./Home/AuthPage/AuthPage.js" import "./Home/ConnectionError.js" import util from "./util.js" +const env = import.meta.env let Global = class { Socket = new Socket() @@ -158,13 +159,14 @@ let Global = class { } async setupPushNotifications() { + if (!Capacitor.isNativePlatform()) return; PushNotifications.addListener('registration', async (token) => { console.log('Device token:', token.value) const stored = localStorage.getItem('deviceToken') if (stored === token.value) return; console.log("new push token") - await server.updatePushToken(token.value) + await server.updatePushToken(token.value, global.profile.id, env.MODE) localStorage.setItem('deviceToken', token.value) }); @@ -184,7 +186,7 @@ let Global = class { const permission = await PushNotifications.requestPermissions(); if (permission.receive === 'granted') { await PushNotifications.register(); - console.log('after registter:') + console.log('after register:') } } @@ -196,7 +198,6 @@ let Global = class { console.error(E) } - this.setupPushNotifications() window.addEventListener("navigate", this.onNavigate) this.getProfile().then(async (status) => { @@ -207,6 +208,7 @@ let Global = class { ConnectionError() } else { await this.Socket.init() + await this.setupPushNotifications() await this.onNavigate() Home() }