My PWA has web-push working with Safari on MacOS (and Chrome and Firefox), but on Safari on iOS 16.4 the ServiceWorkerRegistration object does not contain PushManager:
ServiceWorkerRegistration: {
listeners: {updatefound: Array}
active: ServiceWorker {scriptURL: "http://localhost:9200/sw.js", state: "activated", onstatechange: null, onerror: null, postMessage: function, …}
installing: null
navigationPreload: NavigationPreloadManager {enable: function, disable: function, setHeaderValue: function, getState: function}
onupdatefound: function()
scope: "http://localhost:9200/"
updateViaCache: "imports"
waiting: null
}
I know 16.4 is supposed to support the web-push standard now, so what am I missing?
I've checked that it is not just an issue with the xcode iPhone emulator, I get the same failure on an actual iPhone. I don't know what else to try because it seems like a browser issue.
I figured it out. I was running the PWA in the Safari browser on iOS, which Apple intentionally doesn't support (which is different from Chrome and Firefox). What is supported per the official documentation is "Home Screen web apps in iOS 16.4 or later", which is to say, downloading the PWA to the iPhone home screen and opening it from there. Once I ran the standalone PWA, the ServiceWorkerRegistration included the PushManager.
Side note, web-push notifications still didn't work in the xcode simulator, because they aren't currently supported. When I tried, the app would request permissions and just be stuck there. However, once I tested the same app on an actual iPhone (and downloaded the PWA to the home screen), push notifications were fully functioning!