From 4d3bdcbb6e0f07adb40e81b3b02d7e7ae7832383 Mon Sep 17 00:00:00 2001 From: xeovalyte Date: Sun, 13 Nov 2022 19:48:40 +0100 Subject: [PATCH 1/4] added token notifier --- frontend/app.vue | 6 ++++-- frontend/pages/index.vue | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/app.vue b/frontend/app.vue index e87a32b..7ee388d 100644 --- a/frontend/app.vue +++ b/frontend/app.vue @@ -29,6 +29,7 @@ const route = useRoute() const isAuthenticated = ref(false) const user = ref('frikandel') +const registrationToken = ref('') const auth = ref(null) const userLoaded = ref(false) const userData = ref(null) @@ -118,6 +119,7 @@ const setupNotifications = () => { PushNotifications.addListener('registration', (token) => { // alert('Push registration success, token: ' + token.value); + registrationToken.value = token } ); @@ -223,5 +225,5 @@ const logDeviceInfo = async () => { const ledenlijst = ref([]) -provide('firebase', { db, ledenlijst, isAuthenticated, user, userData, userPersons, auth, userAllPersons, getPersons, calEvents, news }) - \ No newline at end of file +provide('firebase', { db, ledenlijst, isAuthenticated, user, userData, userPersons, auth, userAllPersons, getPersons, calEvents, news, registrationToken }) + diff --git a/frontend/pages/index.vue b/frontend/pages/index.vue index b8efd55..374f187 100644 --- a/frontend/pages/index.vue +++ b/frontend/pages/index.vue @@ -17,6 +17,7 @@ Settings + {{ registrationToken }} @@ -27,5 +28,5 @@ definePageMeta({ title: 'Home', }) -const { userPersons } = inject('firebase') +const { userPersons, registrationToken } = inject('firebase') From 28e9fd8e30a192ed75d6039f2dad2ff89ef10a4b Mon Sep 17 00:00:00 2001 From: xeovalyte Date: Sun, 13 Nov 2022 20:00:29 +0100 Subject: [PATCH 2/4] added subscribe to topic --- frontend/app.vue | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/app.vue b/frontend/app.vue index 7ee388d..4da6253 100644 --- a/frontend/app.vue +++ b/frontend/app.vue @@ -120,6 +120,22 @@ const setupNotifications = () => { (token) => { // alert('Push registration success, token: ' + token.value); registrationToken.value = token + + + fetch('https://api.xeovalyte.com/subscribetotopic', { + method: 'POST', + headers: { + Authorization: 'Basic WGVvdmFseXRlOmtNKjhuRXMzNTchalJlXm1KYnZrRSFOIw==', + 'content-type': 'application/json' + }, + body: JSON.stringify({ topic: 'all', registrationToken: currentToken }) + }).then(response => response.json()) + .then(response => { + console.log(response) + }) + .catch(err => { + console.log(err) + }); } ); From 767b9831b9f1f29ca301c53abe3f4cd940e86c4b Mon Sep 17 00:00:00 2001 From: xeovalyte Date: Sun, 13 Nov 2022 20:13:40 +0100 Subject: [PATCH 3/4] added subscribe to topic --- frontend/app.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app.vue b/frontend/app.vue index 4da6253..cff4058 100644 --- a/frontend/app.vue +++ b/frontend/app.vue @@ -128,7 +128,7 @@ const setupNotifications = () => { Authorization: 'Basic WGVvdmFseXRlOmtNKjhuRXMzNTchalJlXm1KYnZrRSFOIw==', 'content-type': 'application/json' }, - body: JSON.stringify({ topic: 'all', registrationToken: currentToken }) + body: JSON.stringify({ topic: 'all', registrationToken: token.value }) }).then(response => response.json()) .then(response => { console.log(response) From 47b1f776f48115c38dec2486f42860b82d666482 Mon Sep 17 00:00:00 2001 From: xeovalyte Date: Sun, 13 Nov 2022 20:22:43 +0100 Subject: [PATCH 4/4] removed temp message --- frontend/pages/index.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/pages/index.vue b/frontend/pages/index.vue index 374f187..f3cfe6a 100644 --- a/frontend/pages/index.vue +++ b/frontend/pages/index.vue @@ -17,7 +17,6 @@ Settings - {{ registrationToken }}