admin管理员组文章数量:1201991
I have a PWA that should open a specific page when a notification is clicked. Right now I'm testing on iPhone 18.1.1, and it works in all scenarios except when the PWA is closed (swiped away). When the PWA is closed and I click on the notification, the PWA navigates to the base URL that I used when saving the app on the home screen. When the PWA is NOT closed and I click on the notification, the PWA navigates to the specified URL.
I have tried different implementations from different threads I've found on SO and other sites. None of the implementations have caused the PWA to navigate to the specific url when being closed.
Here is a minimal example of the code I'm using to open a window when the PWA is not already opened. In this examples there are two strategies I have tried (I'm not using them at the same time). I have tried putting event.waitUntil() around each strategies call.
self.addEventListener("notificationclick", function (event) {
event.preventDefault();
let url = "https://origin/specific-path";
event.notification.close();
event.waitUntil(
self.clients.matchAll({ type: "window", includeUncontrolled: true })
.then((clientsArray) => {
// Code for navigating an open PWA omitted.
// One of the tried strategies.
return clients
.openWindow(notificationURL)
.then(function (newClient) {
newClient.navigate(notificationURL);
});
// Another of the tried strategies.
self.clients
.openWindow(url)
.then((windowClient) => (windowClient ? windowClient.focus() : null));
})
);
});
Note: I think this issue is separate from the other threads here because this is specifically about opening a specific url when the PWA is closed.
本文标签:
版权声明:本文标题:push notification - Clients.openWindow(specificUrl) opens the base url instead of specificUrl when opening closed PWA on iOS - S 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738642738a2104406.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论