feat: Add push notification support with VAPID keys
- Backend: web-push integration with VAPID keys - Push subscription endpoints (GET /api/push/public-key, POST /api/push/subscribe) - In-memory subscription store - Frontend: Auto-subscribe to push after notification permission granted - Service Worker: Push event handler - Send push notifications when torrents complete - Works even when browser is closed
This commit is contained in:
@@ -98,20 +98,23 @@ self.addEventListener('notificationclick', (event) => {
|
||||
);
|
||||
});
|
||||
|
||||
// Push notification event (for future use)
|
||||
// Push notification event
|
||||
self.addEventListener('push', (event) => {
|
||||
console.log('[Service Worker] Push received');
|
||||
console.log('[Service Worker] Push notification received');
|
||||
const data = event.data ? event.data.json() : {};
|
||||
|
||||
const title = data.title || 'VibeTorrent';
|
||||
const options = {
|
||||
body: data.message || 'New notification',
|
||||
icon: '/icon-192.png',
|
||||
badge: '/icon-192.png',
|
||||
body: data.body || 'New notification',
|
||||
icon: data.icon || '/icon-192.png',
|
||||
badge: data.badge || '/icon-192.png',
|
||||
tag: data.tag || 'vibetorrent-notification',
|
||||
requireInteraction: false,
|
||||
};
|
||||
|
||||
console.log('[Service Worker] Showing notification:', title, options);
|
||||
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(data.title || 'VibeTorrent', options)
|
||||
self.registration.showNotification(title, options)
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user