Hi,
I would like to emphasize that I experience some how the exact same issue No. 2.
There is no issue with other browsers / desktop versions, only iOS / Safari (i.e. PWA!) is behaving weired. The subscription is changing randomly. I've tried to get around by repeadetly checking the subscription information gotten from registration.pushManager.getSubscription() and compare with a local copy, and in case of differences, send the subscription information to my backend to get around this. This works very well for desktop / browser on desktop, but not really on iOS/PWA. From what I saw, it is not the pushManager, but the registration which was not given back correctly and therefore not pushManager.getSubscription() was possible. Nevertheless, and I believe this is the most important point: When there is no change to the application / pwa, why does the subscription information change, i.e. is not stable?
Another thread on github (https://github.com/firebase/firebase-js-sdk/issues/8010) related to firebase and some kind of similar problem finally conviced everybody that this is actually a bug in Webkit.
Actually Web Push Notifications are mission critical for my PWA and I would like to draw attention from Apple to this.
My current sample implementation is:
`self.addEventListener('push', function (event) {
console.log("ServiceWorker: Eingehende Push Nachricht:", event);
let data = {};
try {
data = event.data ? event.data.json() : {};
console.log("Parsed Push Data:", data);
// Benachrichtigung anzeigen, falls gültige Daten vorliegen
if (data.head && data.body) {
event.waitUntil(self.registration.showNotification(data.head, {
body: data.body,
icon: data.icon || '/default-icon.png',
}));
} else {
event.waitUntil(self.registration.showNotification(('Unbekannte Nachricht', {
body: 'Die Nachricht hat eine falsche Struktur',
})));
}
} catch (e) {
console.error("Fehler beim Verarbeiten der Push-Daten:", e);
event.waitUntil(self.registration.showNotification('Unbekannte Nachricht', {
body: 'Die Nachricht konnte nicht gelesen werden.',
}));
}
// Nachricht an alle Clients senden
event.waitUntil(sendToClients(data));
});`
Especially keep in mind the event.waitUntil() call for the showNotification at the end seemed to be quite important as cited by some other sites.
I'm looking forward to get this issue solved soon.