With the new features in WebKit 16.4 it is now possible to use Web Push on Apple devices. The function was quite easy to install. Unfortunately, however, I run into a problem. When I click on the notification, I want to go to a specific page within the Progressive Web App. This works fine in Chrome. In Safari, I always get to the home page of the PWA.
This is my used code within the ServiceWorker:
self.addEventListener('notificationclick', function (event) { console.log('On notification click: ', event); event.waitUntil( clients.matchAll({ type: 'window', }) .then((clientList) => { for (const client of clientList) { if (client.url === url && 'focus' in client) { return client.focus(); } } return clients.openWindow('/calendar'); // does not work. It opens the url "/" instead of "/calendar" }) ); event.notification.close();})
Also, I tried to give the notification from iOS multiple actions. These are not displayed at all. In Chrome it works.
I tried debugging it with a connected iPhone which runs on iOS 16 Public Beta and Safari Technology Preview which has the WebKit 16.4 changes integrated.
I would expect the notification actions to be displayed and a specific link within the PWA to be opened when clicking the notification or an action in the notification.
Are these two functions I use not yet implemented with iOS 16.4 ? Maybe someone has an idea if or when this will be supported or if I'm doing something wrong.