diff --git a/frontend/app.vue b/frontend/app.vue index 2721b98..c2796f9 100644 --- a/frontend/app.vue +++ b/frontend/app.vue @@ -20,6 +20,7 @@ import { doc, getFirestore, serverTimestamp, writeBatch, collection, getDoc } from "firebase/firestore"; import { getAuth, onAuthStateChanged, signInWithEmailAndPassword } from "firebase/auth"; import { PushNotifications } from '@capacitor/push-notifications'; +import { Device } from '@capacitor/device'; const db = getFirestore() const route = useRoute() @@ -34,6 +35,15 @@ const userAllPersons = ref([]) const calEvents = ref([]) const news = ref(null) +if (process.client) { + window.addEventListener('load', () => { + if (!('serviceWorker' in navigator)) { + throw new Error('serviceWorker is not supported in current browser!') + } + navigator.serviceWorker.register('/sw.js') + }) +} + onMounted(() => { auth.value = getAuth() @@ -55,7 +65,7 @@ onMounted(() => { isAuthenticated.value = true - setupNotifications() + logDeviceInfo() } else { isAuthenticated.value = false @@ -125,6 +135,14 @@ const setupNotifications = () => { ); } +const logDeviceInfo = async () => { + const info = await Device.getInfo(); + + console.log(info); + + if (info.platform !== 'web') setupNotifications() +}; + const ledenlijst = ref([]) provide('firebase', { db, ledenlijst, isAuthenticated, user, userData, userPersons, auth, userAllPersons, getPersons, calEvents, news }) diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index 0df482f..8dbb65f 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -9,4 +9,15 @@ export default defineNuxtConfig({ build: { transpile: ['vue-toastification'], }, + meta: { + title: 'WRB App', + charset: 'utf-8', + meta: [ + { name: 'theme-color', content: '#eb6330' } + ], + link: [ + { rel: 'manifest', href: '/manifest.json' }, + { rel: 'icon', href: '/favicon.ico', type: 'image/x-icon' } + ] + } }) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 50ce949..ad629e6 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -7,6 +7,7 @@ "hasInstallScript": true, "dependencies": { "@capacitor/core": "^4.3.0", + "@capacitor/device": "^4.0.1", "@capacitor/ios": "^4.3.0", "@capacitor/push-notifications": "^4.1.0", "@formkit/nuxt": "^1.0.0-beta.11-c95e605", @@ -585,6 +586,14 @@ "tslib": "^2.1.0" } }, + "node_modules/@capacitor/device": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@capacitor/device/-/device-4.0.1.tgz", + "integrity": "sha512-D0jJFQYifmsgcz4X9MEEKH5E36ARK2CJcUCXJbcuFTChHSxK+ly7Kd6PZC73Y5GkEZIjpebWAWo5F3w9S4hsYQ==", + "peerDependencies": { + "@capacitor/core": "^4.0.0" + } + }, "node_modules/@capacitor/ios": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-4.3.0.tgz", @@ -11282,6 +11291,12 @@ "tslib": "^2.1.0" } }, + "@capacitor/device": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@capacitor/device/-/device-4.0.1.tgz", + "integrity": "sha512-D0jJFQYifmsgcz4X9MEEKH5E36ARK2CJcUCXJbcuFTChHSxK+ly7Kd6PZC73Y5GkEZIjpebWAWo5F3w9S4hsYQ==", + "requires": {} + }, "@capacitor/ios": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-4.3.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index e06a67b..45bc280 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -18,6 +18,7 @@ }, "dependencies": { "@capacitor/core": "^4.3.0", + "@capacitor/device": "^4.0.1", "@capacitor/ios": "^4.3.0", "@capacitor/push-notifications": "^4.1.0", "@formkit/nuxt": "^1.0.0-beta.11-c95e605", diff --git a/frontend/public/android/android-launchericon-144-144.png b/frontend/public/android/android-launchericon-144-144.png new file mode 100644 index 0000000..9c0d51b Binary files /dev/null and b/frontend/public/android/android-launchericon-144-144.png differ diff --git a/frontend/public/android/android-launchericon-192-192.png b/frontend/public/android/android-launchericon-192-192.png new file mode 100644 index 0000000..ced0aea Binary files /dev/null and b/frontend/public/android/android-launchericon-192-192.png differ diff --git a/frontend/public/android/android-launchericon-48-48.png b/frontend/public/android/android-launchericon-48-48.png new file mode 100644 index 0000000..ba8e6cf Binary files /dev/null and b/frontend/public/android/android-launchericon-48-48.png differ diff --git a/frontend/public/android/android-launchericon-512-512.png b/frontend/public/android/android-launchericon-512-512.png new file mode 100644 index 0000000..784976b Binary files /dev/null and b/frontend/public/android/android-launchericon-512-512.png differ diff --git a/frontend/public/android/android-launchericon-72-72.png b/frontend/public/android/android-launchericon-72-72.png new file mode 100644 index 0000000..b38b8e3 Binary files /dev/null and b/frontend/public/android/android-launchericon-72-72.png differ diff --git a/frontend/public/android/android-launchericon-96-96.png b/frontend/public/android/android-launchericon-96-96.png new file mode 100644 index 0000000..a5ac9bf Binary files /dev/null and b/frontend/public/android/android-launchericon-96-96.png differ diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico new file mode 100644 index 0000000..c6c4f70 Binary files /dev/null and b/frontend/public/favicon.ico differ diff --git a/frontend/public/ios/100.png b/frontend/public/ios/100.png new file mode 100644 index 0000000..d77a7fa Binary files /dev/null and b/frontend/public/ios/100.png differ diff --git a/frontend/public/ios/1024.png b/frontend/public/ios/1024.png new file mode 100644 index 0000000..1737743 Binary files /dev/null and b/frontend/public/ios/1024.png differ diff --git a/frontend/public/ios/114.png b/frontend/public/ios/114.png new file mode 100644 index 0000000..d1a0227 Binary files /dev/null and b/frontend/public/ios/114.png differ diff --git a/frontend/public/ios/120.png b/frontend/public/ios/120.png new file mode 100644 index 0000000..01049fa Binary files /dev/null and b/frontend/public/ios/120.png differ diff --git a/frontend/public/ios/128.png b/frontend/public/ios/128.png new file mode 100644 index 0000000..e5d3834 Binary files /dev/null and b/frontend/public/ios/128.png differ diff --git a/frontend/public/ios/144.png b/frontend/public/ios/144.png new file mode 100644 index 0000000..9c0d51b Binary files /dev/null and b/frontend/public/ios/144.png differ diff --git a/frontend/public/ios/152.png b/frontend/public/ios/152.png new file mode 100644 index 0000000..047cad7 Binary files /dev/null and b/frontend/public/ios/152.png differ diff --git a/frontend/public/ios/16.png b/frontend/public/ios/16.png new file mode 100644 index 0000000..2f1505c Binary files /dev/null and b/frontend/public/ios/16.png differ diff --git a/frontend/public/ios/167.png b/frontend/public/ios/167.png new file mode 100644 index 0000000..9851aa3 Binary files /dev/null and b/frontend/public/ios/167.png differ diff --git a/frontend/public/ios/180.png b/frontend/public/ios/180.png new file mode 100644 index 0000000..883a821 Binary files /dev/null and b/frontend/public/ios/180.png differ diff --git a/frontend/public/ios/192.png b/frontend/public/ios/192.png new file mode 100644 index 0000000..ced0aea Binary files /dev/null and b/frontend/public/ios/192.png differ diff --git a/frontend/public/ios/20.png b/frontend/public/ios/20.png new file mode 100644 index 0000000..d691a33 Binary files /dev/null and b/frontend/public/ios/20.png differ diff --git a/frontend/public/ios/256.png b/frontend/public/ios/256.png new file mode 100644 index 0000000..0447dbf Binary files /dev/null and b/frontend/public/ios/256.png differ diff --git a/frontend/public/ios/29.png b/frontend/public/ios/29.png new file mode 100644 index 0000000..cc45c42 Binary files /dev/null and b/frontend/public/ios/29.png differ diff --git a/frontend/public/ios/32.png b/frontend/public/ios/32.png new file mode 100644 index 0000000..b3e0a0b Binary files /dev/null and b/frontend/public/ios/32.png differ diff --git a/frontend/public/ios/40.png b/frontend/public/ios/40.png new file mode 100644 index 0000000..be4f930 Binary files /dev/null and b/frontend/public/ios/40.png differ diff --git a/frontend/public/ios/50.png b/frontend/public/ios/50.png new file mode 100644 index 0000000..de3df75 Binary files /dev/null and b/frontend/public/ios/50.png differ diff --git a/frontend/public/ios/512.png b/frontend/public/ios/512.png new file mode 100644 index 0000000..784976b Binary files /dev/null and b/frontend/public/ios/512.png differ diff --git a/frontend/public/ios/57.png b/frontend/public/ios/57.png new file mode 100644 index 0000000..44b73b5 Binary files /dev/null and b/frontend/public/ios/57.png differ diff --git a/frontend/public/ios/58.png b/frontend/public/ios/58.png new file mode 100644 index 0000000..4802674 Binary files /dev/null and b/frontend/public/ios/58.png differ diff --git a/frontend/public/ios/60.png b/frontend/public/ios/60.png new file mode 100644 index 0000000..4a082b3 Binary files /dev/null and b/frontend/public/ios/60.png differ diff --git a/frontend/public/ios/64.png b/frontend/public/ios/64.png new file mode 100644 index 0000000..2f27d8d Binary files /dev/null and b/frontend/public/ios/64.png differ diff --git a/frontend/public/ios/72.png b/frontend/public/ios/72.png new file mode 100644 index 0000000..b38b8e3 Binary files /dev/null and b/frontend/public/ios/72.png differ diff --git a/frontend/public/ios/76.png b/frontend/public/ios/76.png new file mode 100644 index 0000000..227c882 Binary files /dev/null and b/frontend/public/ios/76.png differ diff --git a/frontend/public/ios/80.png b/frontend/public/ios/80.png new file mode 100644 index 0000000..63e8fa3 Binary files /dev/null and b/frontend/public/ios/80.png differ diff --git a/frontend/public/ios/87.png b/frontend/public/ios/87.png new file mode 100644 index 0000000..c67244b Binary files /dev/null and b/frontend/public/ios/87.png differ diff --git a/frontend/public/manifest.json b/frontend/public/manifest.json new file mode 100644 index 0000000..15d3b3a --- /dev/null +++ b/frontend/public/manifest.json @@ -0,0 +1,140 @@ +{ + "name": "WRB App", + "short_name": "WRB", + "theme_color": "#ffffff", + "background_color": "#eb6330", + "display": "standalone", + "orientation": "portrait", + "scope": "/", + "start_url": "/", + "icons": [ + { + "src": "android/android-launchericon-512-512.png", + "sizes": "512x512" + }, + { + "src": "android/android-launchericon-192-192.png", + "sizes": "192x192" + }, + { + "src": "android/android-launchericon-144-144.png", + "sizes": "144x144" + }, + { + "src": "android/android-launchericon-96-96.png", + "sizes": "96x96" + }, + { + "src": "android/android-launchericon-72-72.png", + "sizes": "72x72" + }, + { + "src": "android/android-launchericon-48-48.png", + "sizes": "48x48" + }, + { + "src": "ios/16.png", + "sizes": "16x16" + }, + { + "src": "ios/20.png", + "sizes": "20x20" + }, + { + "src": "ios/29.png", + "sizes": "29x29" + }, + { + "src": "ios/32.png", + "sizes": "32x32" + }, + { + "src": "ios/40.png", + "sizes": "40x40" + }, + { + "src": "ios/50.png", + "sizes": "50x50" + }, + { + "src": "ios/57.png", + "sizes": "57x57" + }, + { + "src": "ios/58.png", + "sizes": "58x58" + }, + { + "src": "ios/60.png", + "sizes": "60x60" + }, + { + "src": "ios/64.png", + "sizes": "64x64" + }, + { + "src": "ios/72.png", + "sizes": "72x72" + }, + { + "src": "ios/76.png", + "sizes": "76x76" + }, + { + "src": "ios/80.png", + "sizes": "80x80" + }, + { + "src": "ios/87.png", + "sizes": "87x87" + }, + { + "src": "ios/100.png", + "sizes": "100x100" + }, + { + "src": "ios/114.png", + "sizes": "114x114" + }, + { + "src": "ios/120.png", + "sizes": "120x120" + }, + { + "src": "ios/128.png", + "sizes": "128x128" + }, + { + "src": "ios/144.png", + "sizes": "144x144" + }, + { + "src": "ios/152.png", + "sizes": "152x152" + }, + { + "src": "ios/167.png", + "sizes": "167x167" + }, + { + "src": "ios/180.png", + "sizes": "180x180" + }, + { + "src": "ios/192.png", + "sizes": "192x192" + }, + { + "src": "ios/256.png", + "sizes": "256x256" + }, + { + "src": "ios/512.png", + "sizes": "512x512" + }, + { + "src": "ios/1024.png", + "sizes": "1024x1024" + } + ] + } \ No newline at end of file diff --git a/frontend/public/sw.js b/frontend/public/sw.js new file mode 100644 index 0000000..1eeff8b --- /dev/null +++ b/frontend/public/sw.js @@ -0,0 +1,48 @@ +importScripts('https://cdn.jsdelivr.net/npm/workbox-cdn/workbox/workbox-sw.js') + +self.addEventListener('install', () => { + self.skipWaiting() +}) + +self.addEventListener('activate', () => { + self.clients.claim() +}) + +// Navigation route are handled by network first strategy +workbox.routing.registerRoute( + ({ request }) => request.mode === 'navigate', + new workbox.strategies.NetworkFirst({ cacheName: 'navigation' }) +) + +// CSS are handled by a Stale While Revalidate strategy +workbox.routing.registerRoute( + ({ request }) => request.destination === 'style', + new workbox.strategies.StaleWhileRevalidate({ + cacheName: 'assets', + plugins: [ + // Ensure that only requests that result in a 200 status are cached + new workbox.cacheableResponse.CacheableResponse({ + statuses: [200] + }) + ] + }) +) + +// Images are handled with a Cache First strategy +workbox.routing.registerRoute( + ({ request }) => request.destination === 'image', + new workbox.strategies.CacheFirst({ + cacheName: 'images', + plugins: [ + // Ensure that only requests that result in a 200 status are cached + new workbox.cacheableResponse.CacheableResponse({ + statuses: [200] + }), + // Don't cache more than 50 items, and expire them after 30 days + new workbox.expiration.CacheExpiration('images', { + maxEntries: 50, + maxAgeSeconds: 60 * 60 * 24 * 30 // 30 Days + }) + ] + }) +) \ No newline at end of file diff --git a/frontend/resources/icon.png b/frontend/resources/icon.png new file mode 100644 index 0000000..873cd19 Binary files /dev/null and b/frontend/resources/icon.png differ diff --git a/frontend/resources/splash.png b/frontend/resources/splash.png new file mode 100644 index 0000000..2b744e6 Binary files /dev/null and b/frontend/resources/splash.png differ