In the following patch, I'm adding a runtime feature setting enabling the embedder to disable non-Service Worker based notifications. We will be disabling them for Android.
This creates somewhat of a discrepancy between desktop platforms and Android, so I want to make sure that people are aware of this.
To clarify terminology:
- A persistent notification is a Service Worker-based one created through ServiceWorkerRegistration.showNotification().
- A non-persistent notification is one where events get delivered on the created JavaScript object, through "new Notification()".
On desktop, we currently support both. We can rely on the fact that the renderer processes associated with non-visible tabs continue live, allowing the notification to be interacted with. Only after the user closes the tab the notification will go unresponsive.
On Android, we will only support the Service Worker-based Notifications, and will throw a type error when the Notification object gets constructed. We do not control the lifetime of renderer processes on that platform, which means that non-SW based notifications will go unresponsive after an arbitrary amount of time - which could be immediate. This creates a very bad user experience.
In the long run, we want to either change behavior of or deprecate notifications created through the Notification constructor. This is being discussed on the following locations:
Unfortunately this is not feasible as of yet, not least of all because we're the first shipping Service Worker notifications. There also are a number of large users of notifications on desktop. The absence of notifications on the mobile Web, as well as desktop UMA, indicate that this is very unlikely to be a web-incompatible decision.
I hope this clarifies it! Let me know if there are any concerns.
Thanks,
Peter