diff --git a/frontend/app.vue b/frontend/app.vue index 822f324..14f13c2 100644 --- a/frontend/app.vue +++ b/frontend/app.vue @@ -32,6 +32,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) @@ -121,6 +122,23 @@ const setupNotifications = () => { PushNotifications.addListener('registration', (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: token.value }) + }).then(response => response.json()) + .then(response => { + console.log(response) + }) + .catch(err => { + console.log(err) + }); } ); @@ -226,5 +244,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..f3cfe6a 100644 --- a/frontend/pages/index.vue +++ b/frontend/pages/index.vue @@ -27,5 +27,5 @@ definePageMeta({ title: 'Home', }) -const { userPersons } = inject('firebase') +const { userPersons, registrationToken } = inject('firebase')