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

问题描述 投票:0回答:1

借助 WebKit 16.4 中的新功能,现在可以在 Apple 设备上使用 Web Push。该功能非常容易安装。然而不幸的是,我遇到了一个问题。当我点击通知时,我想转到 Progressive Web App 中的特定页面。这在 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();
})

此外,我尝试从 iOS 发出多项操作的通知。这些根本不显示。在 Chrome 中它有效。

我尝试使用连接的 iPhone 调试它,该 iPhone 在 iOS 16 公共测试版和集成了 WebKit 16.4 更改的 Safari 技术预览版上运行。

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

我用的这两个功能是不是iOS 16.4还没有实现?也许有人知道是否或何时会支持,或者我是否做错了什么。

javascript ios safari progressive-web-apps service-worker
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.