Topher Hunt
Topher Hunt

Reputation: 4804

Notification requireInteraction setting broken in Chrome?

I'm familiarizing with the browser notification API, and I can't seem to get the requireInteraction setting to work in Chrome (I'm on Mac OSX, Chrome v89.0.4389.114.) I'd like help confirming whether this is a known Chrome bug, or maybe I'm just doing something wrong.

After granting notification permission, running the following command from console displays a transient notification, as expected, which disappears after ~5 seconds:

new Notification("Test", {body: "Foo", requireInteraction: false})

...whereas the following command does not display any notification, even momentarily (though the console shows a returned Notification object that appears to have the right values set):

new Notification("Test", {body: "Foo", requireInteraction: true})

In other words, in all my testing so far, requireInteraction=true causes the notification to not be shown at all, even though the notification displays correctly if requireInteraction=false.

I understand Chrome has a reputation for repeatedly breaking standard JS APIs without warning, but I'm surprised that I can't find any current documentation confirming that this is a known problem. (Relatedly, requireInteraction doesn't seem to have any effect on Firefox v86.0.1 either. But I'll troubleshoot that separately.) I guess I expected the Notification API to be more stabilized than this by now.

Can any helpful people confirm whether the requireInteraction setting works for you on latest Chrome (ideally on OSX to minimize any possible platform differences)? Is this a browser bug? Maybe an OSX limitation? Am I using the setting wrong? Or is this a known issue that should be reflected in MDN's browser compatibility table? Thanks in advance!

Upvotes: 1

Views: 1362

Answers (2)

Trevor Shibley
Trevor Shibley

Reputation: 43

Update here: It looks like Chrome has changed the way they register notification permissions on Mac, so now there are 2 "apps" that have permission settings: one for alerts, and one for everything else. If you toggle the Alerts helper on, then requireInteraction: true notifications should work!

So, the same advice as the previous answer applies 😁

So: if requireInteraction isn't working for you, check your OS notification settings!

Screenshot of settings showing two chrome notification options

Upvotes: 0

Topher Hunt
Topher Hunt

Reputation: 4804

Answer: after giving up on this for a couple months, I took a closer look and realized that my Mac OSX notification settings for Chrome were set to "Banners", but needed to be set to "Alerts". When the OSX notification setting is set to "Banners", Chrome notifications will only be shown for a couple seconds then will be hidden, regardless of the requireInteraction option. Chrome's dev tools give no indication of this, I assume because Chrome can't see the OS-level settings so the browser doesn't realize that the notifications aren't sticking.

enter image description here

So: if requireInteraction isn't working for you, check your OS notification settings!

Upvotes: 6

Related Questions