diff --git a/src/service-worker.ts b/src/service-worker.ts index cf75c382..0e04db34 100644 --- a/src/service-worker.ts +++ b/src/service-worker.ts @@ -23,25 +23,21 @@ const ICONS = { self.addEventListener('push', (event: PushEvent) => { if (!event.data) return; - let title = 'Stocknear'; + let title = ''; // Use an empty title to suppress "von Stocknear" let body: string; try { - // Try to get the payload as text first const payload = event.data.text(); try { - // Try to parse as JSON const jsonData = JSON.parse(payload); if (jsonData.title) { - title = jsonData.title; + title = jsonData.title; // Use title from payload if provided body = jsonData.body; } else { - // If no title in JSON, use the entire payload as body body = payload; } } catch { - // If JSON parsing fails, use the payload as body body = payload; } } catch { @@ -57,8 +53,9 @@ self.addEventListener('push', (event: PushEvent) => { tag: 'stocknear-notification', renotify: true, vibrate: [200, 100, 200], + silent: true, // Prevents Apple from modifying the notification data: { - suppressNotificationFrom: true // Custom flag to indicate branding should be suppressed + suppressNotificationFrom: true } }; @@ -66,6 +63,8 @@ self.addEventListener('push', (event: PushEvent) => { self.registration.showNotification(title, options) ); }); + + /** * Notification click handler * Handles user interaction with notifications