bugfixing
This commit is contained in:
parent
d664a6c4a7
commit
4914999165
@ -23,21 +23,25 @@ const ICONS = {
|
|||||||
self.addEventListener('push', (event: PushEvent) => {
|
self.addEventListener('push', (event: PushEvent) => {
|
||||||
if (!event.data) return;
|
if (!event.data) return;
|
||||||
|
|
||||||
let title = ''; // Use an empty title to suppress "von Stocknear"
|
let title = 'Stocknear';
|
||||||
let body: string;
|
let body: string;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Try to get the payload as text first
|
||||||
const payload = event.data.text();
|
const payload = event.data.text();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Try to parse as JSON
|
||||||
const jsonData = JSON.parse(payload);
|
const jsonData = JSON.parse(payload);
|
||||||
if (jsonData.title) {
|
if (jsonData.title) {
|
||||||
title = jsonData.title; // Use title from payload if provided
|
title = jsonData.title;
|
||||||
body = jsonData.body;
|
body = jsonData.body;
|
||||||
} else {
|
} else {
|
||||||
|
// If no title in JSON, use the entire payload as body
|
||||||
body = payload;
|
body = payload;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
// If JSON parsing fails, use the payload as body
|
||||||
body = payload;
|
body = payload;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@ -53,9 +57,8 @@ self.addEventListener('push', (event: PushEvent) => {
|
|||||||
tag: 'stocknear-notification',
|
tag: 'stocknear-notification',
|
||||||
renotify: true,
|
renotify: true,
|
||||||
vibrate: [200, 100, 200],
|
vibrate: [200, 100, 200],
|
||||||
silent: true, // Prevents Apple from modifying the notification
|
|
||||||
data: {
|
data: {
|
||||||
suppressNotificationFrom: true
|
suppressNotificationFrom: true // Custom flag to indicate branding should be suppressed
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,8 +66,6 @@ self.addEventListener('push', (event: PushEvent) => {
|
|||||||
self.registration.showNotification(title, options)
|
self.registration.showNotification(title, options)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification click handler
|
* Notification click handler
|
||||||
* Handles user interaction with notifications
|
* Handles user interaction with notifications
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user