[Webkit-unassigned] [Bug 252544] New: Non-opened Home Screen web app can not receive post message from Notificationclick callback

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Feb 19 04:15:46 PST 2023


https://bugs.webkit.org/show_bug.cgi?id=252544

            Bug ID: 252544
           Summary: Non-opened Home Screen web app can not receive post
                    message from Notificationclick callback
           Product: WebKit
           Version: Safari 16
          Hardware: iPhone / iPad
                OS: iOS 16
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebKit API
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: hi at lehu.in

Overview: 

I made a Home Screen web app, which register a service worker to handle the push events
triggered by the WebPush. And in the notificationclick callback function, I try to open
the web app calling the clients.openWindow() function. Then, I try to post some message
with the postMessage method. In my web app's js, I have registered the "message" event
handler for navigator.serviceWorker, which should be called when receive the message
from the notificationclick callback.

If the Home Screen web app is not open, it can be opened by touch the APNS message.
However, the web app's js can not receive the posted message from the service worker.

After it has been opened, the following push which will post message from the service
worker will be received.

Steps to Reproduce:

1) Upgrade iOS to 16.4 beta1

2) Open the following experimental features of Safari:
  a) Notifications
  b) Push API

3) Make a web app and add it to the Home Screen

4) Register Service Worker and handle the events

In the service worker:

async function openPushNotification(event) {
  event.notification.close();
  event.waitUntil((async () => {
    let w = await clients.openWindow(event.notification.data);
    w.postMessage(event.notification.data);
  })());
}
self.addEventListener("notificationclick", openPushNotification);

In the web app:

navigator.serviceWorker.addEventListener("message", (event) => {
  console.log(event.data);
  let wn = document.getElementById("web-notification");
  wn.innerHTML = JSON.stringify(event.data, null, " ");
});

5) Close the Home Screen web app.

6) Click the APNS notification.

Actual Results:

The "message" event callback will not triggered if the web app is not opened.

Expected Results:

Every time we click the WebPush notification, which will open the Home Screen
web app, it should always receive the post message sent by the notificationclick handler.

Build Date & Hardware:

iOS 16.4 (20E5212f) beta1

Additional Builds and Platforms:

iPhone SE 3rd

Additional Information:

I have tested the Firefox 110 and Safari 16.3 on macOS 13.2.1, both of which
support receiving the post message.

-- 
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/20230219/243e07dc/attachment.htm>


More information about the webkit-unassigned mailing list