bugfixing

This commit is contained in:
MuslemRahimi 2025-02-02 23:38:04 +01:00
parent 56af74dca0
commit d664a6c4a7

View File

@ -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