[Webkit-unassigned] [Bug 263687] New: notificationClick openWindow goes to PWA root instead of url given
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Oct 25 15:08:56 PDT 2023
https://bugs.webkit.org/show_bug.cgi?id=263687
Bug ID: 263687
Summary: notificationClick openWindow goes to PWA root instead
of url given
Product: WebKit
Version: Safari 17
Hardware: iPhone / iPad
OS: iOS 17
Status: NEW
Severity: Major
Priority: P2
Component: WebKit API
Assignee: webkit-unassigned at lists.webkit.org
Reporter: mark.romano at oracle.com
Overview:
What I'm seeing is similar to https://bugs.webkit.org/show_bug.cgi?id=252544#c18 but I didn't find a logged bug.
Steps to Reproduce:
Service Worker handles push/notificationclick where the event data can contain a deeplink to open.
Install the PWA on Home Screen.
Close the PWA app.
Tap a Notification with a deeplink in the data.
notificationclick calls clients.openWindow() with the deeplink.
Actual Results:
PWA is opened, but to the pwa root url.
Expected Results:
PWA is opened to the deeplink url sent to openWindow().
This is the behavior seen if the PWA is already open.
Build Date & Hardware:
iPhone 14 MPUA3LL/A, iOS Version 17.0.3 (21A360)
Additional Information:
Contrary to the link above, I know that the service worker is handling the push event because I added "sw-" to the title sent to showNotification(), to confirm.
I also am struggling with similar Safari devtools behavior:
"In this case, I cannot open the Safari devtools for the service worker running on my phone, it simply isn't listed in the Develop menu under my phone submenu, which is really strange. If I open the app manually then the service worker appears in the menu as expected."
notificationclick handler calls a focus() function with parameters extracted from notification.data:
function focus(event, parameters) {
const destinationUrl = (parameters && parameters.urlPath) ? new URL(parameters.urlPath, appPath).href : appPath;
const matchOptions = {
type: 'window',
includeUncontrolled: false,
};
const result = globalThis.clients.matchAll(matchOptions)
.then((windowClients) => {
// See if there is client for this application already open
const matchingClient = windowClients.find((windowClient) => windowClient.url.startsWith(appPath));
if (matchingClient) {
logger.info('Found a matching client, focussing it');
if (destinationUrl !== appPath) {
return matchingClient.navigate(destinationUrl).then(() => matchingClient.focus());
}
return matchingClient.focus();
}
logger.info('Opening a new client at', destinationUrl);
return globalThis.clients.openWindow(destinationUrl)
.catch((error) => {
logger.error(`openWindow(${destinationUrl}) failed! ${error})`);
});
});
event.waitUntil(result);
}
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20231025/f91fb0f3/attachment.htm>
More information about the webkit-unassigned
mailing list