feat: restructure into XFlow monorepo with Nuxt 4, Modular Onion Monolith, Android client, and Desktop CLI
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export default defineNuxtPlugin(() => {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
console.log('[PWA] Service Worker ready:', registration.scope)
|
||||
})
|
||||
|
||||
// Handle push messages when app is open
|
||||
navigator.serviceWorker.addEventListener('message', event => {
|
||||
if (event.data?.type === 'PUSH_RECEIVED') {
|
||||
const { title, body } = event.data.payload || {}
|
||||
// Local alarm: vibrate and show notification
|
||||
if (navigator.vibrate) {
|
||||
navigator.vibrate([200, 100, 200])
|
||||
}
|
||||
if ('Notification' in window && Notification.permission === 'granted') {
|
||||
new Notification(title || 'XFlow Alarm', {
|
||||
body: body || 'Alarm triggered',
|
||||
icon: '/pwa-192x192.svg',
|
||||
badge: '/favicon.svg',
|
||||
...({ vibrate: [200, 100, 200] } as any)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user