[Webkit-unassigned] [Bug 279277] New: Push notifications stop working
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Sep 6 12:33:41 PDT 2024
https://bugs.webkit.org/show_bug.cgi?id=279277
Bug ID: 279277
Summary: Push notifications stop working
Product: WebKit
Version: Safari 17
Hardware: iPhone / iPad
OS: iOS 17
Status: NEW
Severity: Major
Priority: P2
Component: Service Workers
Assignee: webkit-unassigned at lists.webkit.org
Reporter: fred at slushy.com
CC: youennf at gmail.com
Device deregisters from Web Push sporadically. PWA on iOS using FCM to send push notifications. Device registers and works for a bit but eventually unregisters.
FCM marked the issue is with WebKit:
https://github.com/firebase/firebase-js-sdk/wiki/Known-Issues
https://www.reddit.com/r/PWA/comments/13jx8uq/are_ios_web_push_notifications_reliable/
Here is my service worker:
self.addEventListener('push', function(event) {
event.stopImmediatePropagation();
const {data} = event.data.json(); // Assuming the payload is sent as JSON
const notificationTitle = data?.title;
const notificationOptions = {
data: {
link: data?.link
},
body: data?.body ,
badge: './icons/icon-mono.png',
icon:
data?.senderProfileImage
};
event.waitUntil(
self.registration.showNotification(notificationTitle, notificationOptions)
);
});
self.addEventListener('notificationclick', function (event) {
event.notification.close();
event.waitUntil(
clients
.matchAll({
type: 'window'
})
.then(function (clientList) {
for (var i = 0; i < clientList.length; i++) {
var client = clientList[i];
if (client.url === '/' && 'focus' in client) {
return event?.notification?.data?.link
? client.navigate(
`${self.origin}/${event?.notification?.data?.link}`
)
: client.focus();
}
}
if (clients.openWindow) {
return clients.openWindow(
event?.notification?.data?.link
? `${self.origin}/${event?.notification?.data?.link}`
: '/'
);
}
})
);
});
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240906/652b22f3/attachment-0001.htm>
More information about the webkit-unassigned
mailing list