借助 WebKit 16.4 中的新功能,现在可以在 Apple 设备上使用 Web Push。该功能非常容易安装。然而不幸的是,我遇到了一个问题。当我单击通知时,我想转到渐进式 Web 应用程序中的特定页面。这在 Chrome 中运行良好。在 Safari 中,我总是会访问 PWA 的主页。
这是我在 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();
})
Run Code Online (Sandbox Code Playgroud)
另外,我尝试从 iOS 多个操作发出通知。这些根本不显示。在 Chrome 中它可以工作。

我尝试使用连接的 iPhone …