For those of us who have been waiting, primarily so our Discourse instances work better on iOS, it seems the day is near, as Apple officially announced today support for web push notifications in iOS 16, coming in 2023.
There’s a presentation on it tomorrow:
There’s a little more detail about the implementation here.
Web Push is coming to Safari 16 on macOS Ventura. This lets you remotely send notifications to users of your websites and web apps — and deliver those notifications even when Safari isn’t running. It uses the same combination of web standards you may be familiar with from other browsers: Push API and Notifications API, along with Service Worker.
Users opt into notifications by first indicating interest through a user gesture — such as clicking a button. Then, they’ll be prompted to give permission for your site or app to send notifications. Users will be able to view and manage notifications in Notifications Center, and customize styles and turn notifications off per website in Notifications Settings.
If you’ve already implemented Web Push for your web app or website using industry best practices, it will automatically work in Safari. Although, if you’ve excluded Safari through browser detection, you’ll need to switch to feature detection to get it working.
Web Push in Safari uses the same Apple Push Notification service that powers native push on all Macs and iOS devices. If you tightly manage push endpoints on your server, be sure you allow URLs from any subdomain of push.apple.com. You do not need to be an Apple Developer Program member.
And look for Web Push for iOS and iPadOS in 2023.
macOS Safari has had non-standard web push notifications since 2013, but it’s never worked for iOS before.
This announcement just seems to indicate that macOS Safari will switch to a standards-based API in Safari 16, which is nice, but if you wanted macOS Safari push notifications, you can already implement them today.
iOS support will be the real game changer.
I’m grateful for you providing more detailed info on this!
Do you or does anyone else know how this will impact Discourse instances? I assume it will mean that when someone saves a website to the home screen, then it will allow the user to receive notifications from that Discourse PWA, is that true?
Also, will this allow DiscourseHub to send iOS push notifications to all of the Discourse instances within it?
No, this feature has nothing to do with installing to the home screen or “PWAs.”
“PWA” is sort of a marketing term invented by developers at Google; the term refers to a bundle of features:
- add to home screen (A2HS)
- offline support, so the site/app keeps working when you’re offline
- native-like features (features that used to be exclusive to native apps), including push, bluetooth, background fetch, etc.
But the features have nothing inherently to do with each other. You can have any one of those features without any of the others.
- You can add any web page to your home screen. The web page doesn’t have to have offline support or native-like features to A2HS. (It’s really just adding a bookmark to your home screen; that’s all A2HS does.)
- You can enable offline support for your web site regardless of whether you use A2HS or not.
- There are no native-like features that require you to use A2HS or to use offline support. WebBluetooth works on any web page, as long as the user accepts a “permissions” dialog; you don’t have to A2HS to turn it on.
Today, in Google Chrome and in today’s shipping version of macOS Safari 15, web sites can pop-up a little request dialog, asking permission to push notifications. (You have to do it in a “click” handler or a response to a similar “user gesture” like dragging or swiping.) You’ve probably seen those pop-ups on news sites from time to time.
Apple’s blog post seems to indicate that nothing will change about the permission prompt in Safari 16:
Users opt into notifications by first indicating interest through a user gesture — such as clicking a button. Then, they’ll be prompted to give permission for your site or app to send notifications.
This question is confusing. That’s what Discourse Hub already does today.
I think maybe there was something wrong with my notifications settings on my iPhone where they weren’t arriving:
Ah nice! So people could still get the notifications without A2HS, sounds great, thank you.
I was under the impression that iOS notifications in Discourse Hub only worked for Discourse instances hosted by the Discourse team as per the message below. Has this changed?
As the thread you linked to explains, Discourse Hub can push notifications for any Discourse site, even ones not hosted by the Discourse team, but it only pushes live (instant) notifications for sites hosted by the Discourse team. If you add a non-hosted site to Discourse Hub, you’ll get notifications, but at a slower schedule.
Nonetheless, I don’t think that’s what the question is asking about, but I may have misunderstood:
Discourse Hub can already send iOS push notifications
to from all of the Discourse instances within it. Non-hosted sites send notifications more slowly, but they do send notifications.
Ahh I was indeed hoping that self-hosted sites would send be able to send immediate notifications. Maybe the delay in the notifications was what confused me about whether they were currently being sent or not.
That being said, I’m excited that iOS 16 should enable the immediate ones for self-hosted Discourse sites
Thanks for the clarification. I am mainly interested in live iOS push notifications, not notifications fetched via polling.
“WKWebView” is Apple’s API for embedding a web browser in a native app; Discourse Hub uses WKWebView. As far as I know, today’s existing proprietary macOS Safari 15 push notifications don’t work in a WKWebView on macOS.
Apple makes some native-like features available only in the Safari app, not in a WKWebView, and sometimes not even in web pages saved to the home screen, which technically each run in a separate “Web.app” process on iOS.
We don’t yet know whether the new standard Push API will work in a WKWebView, (so we don’t know whether they’ll work in Discourse Hub), and we certainly don’t know whether Push API will work in a WKWebView on iOS, which isn’t even shipping in 2022.
But, a few more details are supposed to be available at tomorrow’s presentation.
FWIW, it’s typical for Apple Evangelists to refuse to answer further questions about native-like features on the web publicly.
Consider this question posed on Twitter:
Apple has been answering Maximiliano’s questions throughout the day, but, uh, for some reason, just this question has gone unanswered!
Oh goodness, I love this level of detail, thank you for writing it out. Here’s to hoping it will work on the WKWebView in iOS and homescreen apps
I’m glad to see that I wasn’t the only one watching that keynote.
I’m not sure why it won’t debut with the first release of iOS 16, but whatever…
Wasn’t that already available in macOS? I’ve been able to receive able to receive Safari push notifications from MacRumors for years now. Maybe they were using a workaround of some sort?
As I said in my earlier post:
Ah, sorry. I wasn’t entirely sure what you meant by that.
There was very little detail in today’s video. Meet Web Push for Safari - WWDC22 - Videos - Apple Developer
WebKit has a blog post up today.
There’s a little more detail available here.
At the Safari WWDC lounge, a user “John” asked a question, “Will web push work in WKWebView instances?” The answer from “Brady E” at Apple was:
On macOS Ventura, Web Push is only supported in Safari 16.
John followed up: “what about iOS/iPadOS?” to which Brady replied, “Look for iOS/iPadOS support in 2023.” So, they’re not answering any questions today about iOS support.
It seems extremely unlikely to me that Web Push notifications will work in a WKWebView in 2023, especially on iOS, so I expect that Safari Web Push will have no direct benefit to Discourse Hub.
But, of course, the Discourse Hub app will be much less important when Safari Web Push lands.
Thank you for following this with Apple and for writing a follow-up to this here
There are some other benefits to the Discourse Hub application.
You’re mostly correct though. It’ll become partially obsolete soon enough. I wonder if CDCK will ditch it altogether…
BTW, There are no plans on ditching the mobile app, it’s still very useful to be able to aggregate all of your discourse sites and notifications together in one place, separately from receiving real-time notifications
Would it make sense to bring Discourse Hub to the web as a PWA?
That’s unfortunately not something currently on our roadmap, but it’s something I personally would love to see, it’s an great idea