mattermost icon indicating copy to clipboard operation
mattermost copied to clipboard

MM-52219 Add announcement bar to prompt users for notification permission

Open hmhealey opened this issue 10 months ago • 13 comments

Summary

This is a fix for the issue where some browsers prevent us from prompting for notification permission because the app tries to notify the user when the browser isn't focused.

My original plan was for something fancier where we'd wait until the user could've received a notification and then we prompt them for permission when the app next gets focus, but that ended up getting overly complicated, and it changed the existing code which had me worried that something might break.

Instead, I went for the super simple solution of just showing a "give us permission" banner as soon as the app opens like other apps do. This might be mildly annoying to people, but it's simple and hopefully effective enough to do the trick. It also leaves the existing code path in place so, if someone ignores the banner, they'll still get the same permission prompt that we previously trigger.

Ticket Link

MM-52219

Release Note

Added banner to prompt users to give desktop notification permission when opening the app

hmhealey avatar Apr 23 '24 15:04 hmhealey

E2E tests not automatically triggered, because the PR is not in a mergeable state. Please update the branch with the base branch and resolve outstanding conflicts.

mattermost-build avatar Apr 23 '24 15:04 mattermost-build

@hmhealey: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

I understand the commands that are listed here

mm-cloud-bot avatar Apr 23 '24 15:04 mm-cloud-bot

@hmhealey: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

I understand the commands that are listed here

mm-cloud-bot avatar Apr 23 '24 15:04 mm-cloud-bot

@hmhealey: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

I understand the commands that are listed here

mm-cloud-bot avatar Apr 23 '24 15:04 mm-cloud-bot

@hmhealey: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

I understand the commands that are listed here

mm-cloud-bot avatar Apr 23 '24 15:04 mm-cloud-bot

@abhijit-singh Let me know if there's any changes you'd want to see from a user perspective, particularly around the timing the bar appears, the text on the bar, and whether or not we should have a "don't ask me again" button. I didn't add that last one because it seemed redundant with just denying permission, but I'm 0/5 on that.

hmhealey avatar Apr 23 '24 15:04 hmhealey

Creating a new SpinWick test server using Mattermost Cloud.

mm-cloud-bot avatar Apr 26 '24 19:04 mm-cloud-bot

Mattermost test server created! :tada:

Access here: https://mattermost-pr-26849.test.mattermost.cloud

Account Type Username Password
Admin sysadmin Sys@dmin123
User user-1 User-1@123

Your Spinwick's installation ID is: q93h84dg5384ucoiw18fi3chgo To access the logs, please click here

mm-cloud-bot avatar Apr 26 '24 19:04 mm-cloud-bot

/update-branch

harshilsharma63 avatar May 08 '24 04:05 harshilsharma63

@hmhealey if I reject the permission, i.e, disallow it, the notification banner never shows up. I just want to confirm this is intentional.

harshilsharma63 avatar May 08 '24 04:05 harshilsharma63

@hmhealey if I reject the permission, i.e, disallow it, the notification banner never shows up. I just want to confirm this is intentional.

Yeah, that's intended. The browser also prevents you from showing the permission prompt if the user previously denied it as well, so there's no point in prompting the user at the moment. This PR is more to ensure that users see the initial prompt rather than to get them to give us permission after they've denied it.

I think we plan to show that permission was denied in the account settings in the future, but that's separate from this

hmhealey avatar May 08 '24 21:05 hmhealey

Oh right. Sorry, I totally forgot about that case since you definitely mentioned that before

hmhealey avatar May 13 '24 17:05 hmhealey

@abhijit-singh I ended up just removing the z-index from that component entirely since, as far as I can tell, that hasn't been needed for a long time. I think that's a remnant of when the announcement bar used to sometimes overlap the app, and it's no longer needed ever since Caleb made the whole app use CSS grid a couple years ago

hmhealey avatar May 13 '24 21:05 hmhealey

@hmhealey If user blocks this and reloads browser. The banner won't show again. Is this expected?

Screenshot 2024-05-16 at 4 35 42 PM
  • If we allow it from here. The notifications are on, but the banner persists. Unless we reload.
image

yasserfaraazkhan avatar May 16 '24 11:05 yasserfaraazkhan

Yeah, those are both expected.

For the first one, we can't prompt the user to change their permission if they've previously blocked it, so I don't bother showing the bar.

For the second one, we can't detect that the user changed their permissions from outside the web app, so it's normal that the bar doesn't disappear unless the user specifically clicks on "Enable notifications" on it. From my testing, that also matches how Slack behaves

hmhealey avatar May 17 '24 16:05 hmhealey

New commit detected. SpinWick will upgrade if the updated docker image is available.

mm-cloud-bot avatar May 17 '24 17:05 mm-cloud-bot

Mattermost test server updated with git commit 19744de862eb68bbf2d0fe53b92e4a11bb8cd642.

Access here: https://mattermost-pr-26849.test.mattermost.cloud

mm-cloud-bot avatar May 17 '24 18:05 mm-cloud-bot