如何在 iOS 16.4 上的 PWA 中打开自定义 url

pbr*_*bro 5 javascript safari ios service-worker progressive-web-apps

借助 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 进行调试,该 iPhone 在 iOS 16 Public Beta 和集成了 WebKit 16.4 更改的 Safari 技术预览版上运行。

我希望在单击通知或通知中的操作时显示通知操作,并打开 PWA 中的特定链接。

我使用的这两个功能尚未在 iOS 16.4 中实现吗?也许有人知道是否或何时会支持这一点,或者我是否做错了什么。