Web Push notifications on iOS don't route user to any URL on click

AI-generated summary

The issue of Web Push notifications not routing users to the correct URL on click in iOS PWAs has been reported. Initially thought to be an incompatibility in the code at service-worker.js.erb, it is now believed to be a bug in iOS (WebKit bug #252544). A WebKit engineer, Brady Eidson, has identified the issue and submitted a PR to fix it (WebKit PR #11848). According to pmusaraj, this issue is fixed in the current version of iOS (16.5), and they can no longer reproduce the issue. pmusaraj is seeking confirmation from Falco and merefield if they also experience the fix.

When you receive a push notification on the iOS PWA it will correctly open the correct PWA for you.

However, if it’s open already, it won’t route you to the correct target URL of the notification, like for example the post URL on a notification for a reply.

Probably an iOS incompatibility on the code at

https://github.com/discourse/discourse/blob/main/app/assets/javascripts/service-worker.js.erb#L215-L236

First reported by @pmusaraj

6 Likes

Any update on this wrt to the evolving beta releases from Apple?

2 Likes

I have looked into this a bit, and so far it looks like this is a bug in iOS. See: 252544 – Initial ServiceWorkerWindowClient in a Home Screen web app launched to handle notificationclick handler is inert for a short period

They key piece there is probably this comment from Brady Eidson (Webkit engineer):

In my test case it’s working because I’m postMessaging to a new client opened via clients.openWindow
If I attempted to matchAll and reuse an existing window client, I would fall into this same trap.

Looks like Brady has a PR up for this as well: https://github.com/WebKit/WebKit/pull/11848, probably best to wait and see if this gets fixed upstream.

4 Likes

I believe this is fixed in the current version of iOS (16.5), I can’t repro the issue on my phone. Does that check out for you @Falco @merefield ?

2 Likes

This topic was automatically closed after 5 days. New replies are no longer allowed.