Discourse Push Notifications for Desktop

official

(Jeff Wong) #1

The Push notification plugin allows users to opt to receive receive push notifications over desktop devices in addition to mobile devices.

:warning: In order for this plugin to work at all, your Discourse MUST BE HTTPS!

The plugin repository is at github.com/discourse/discourse-push-notifications

While push notifications for mobile are now supported in core by default, they are applicable for mobile devices such as Android only.

This plugin exposes a user option that allows users to prefer push notifications on desktop devices:

prefer-push

When checked, enabling “live notifications” will prefer push notifications on desktop devices.

Why?

Desktop browsers are able to get “desktop notifications” which work just fine! However there is a subtle difference in the way that the two function. With desktop notifications, the moment that you close your tabs to discourse, notifications cease to come through. With a push notification, this is not the case.

With push notifications, it is not necessary to have a browser tab open in order to receive notifications. A user is able to receive notifications even when there is no browser tab open on the Discourse site.

Supported Browsers

Chrome Desktop 51 and up, Firefox Desktop 44 and up, see caniuse for specifics.

Installation

Be on a recent version of Discourse running HTTPS, then follow Install a Plugin.


Discourse Push Notifications
Wrong avatar is shown
#4

Are you suppose to get push notifications for all things that you would get notified for with numbers in the avatar bubble (i.e. also watched topics) or only replies and @usernames?


(Jeff Wong) #5

Yes, any watched topics apply as well. A good rule of thumb here is you will receive notifications for anything you would be notified about via email. So events like @ notifications, PMs, watched topics/categories, but not when someone likes your post.

(also keep in mind that the push functionality is now a core feature as of today – this plugin is now only for those who prefer push notifications on their desktop as well)


#6

This just happened - I was writing out a new topic on meta when a push notification (also for meta) came in. It flickered a bunch before settling down. I’ll follow up if I see something like that again on my site or here.

EDIT: Happened again - was on a different tab. Notification flickered 2 or 3 times. I’ll try and find time with someone to test this out.


(Jeff Wong) #8

Hm, I haven’t noticed that behavior in my time working on this. What browser are you using?

Shot in the dark, if you unsubscribe, and re-subscribe, does that resolve the flickering?

I’ll look into a cause for this, thanks for reporting back!

We’ve repurposed the plugin so that there wouldn’t have to be any name changes.

Regarding your issue with no notifications and not being able to re-enable, are there any associated error logs that you could share?


(Jeff Wong) #20

This was due to a bug in core with push notifications - It started happening to me too, and was the most noticeable on desktop. Fixed here: FIX: de-duplicate push subscriptions - ensure unique user/key · discourse/discourse@7f1f697 · GitHub


(Stephen) #21

Thank god, I was getting three at a time. Nice to know it’s going away.

On the other matter above, @featheredtoast and I figured out via DM that there was some kind of key issue at play. We wiped out those variables and when they were regenerated on the next restart it all began working.


(RBoy) #22

Okay I’m a little confused now. I see three things and all are official:

  1. Live notifications in the notifications tab of each user (no plugins installed as yet)
  2. Push Notifications for Desktop (this plugin)
  3. Discourse Push Notifications plugin

How are these 3 different?


(Jeff Wong) #23

Sorry you’re right, I should have unlisted the older plugin earlier. It was repurposed once notifications were available on Android by default.

Discourse has slowly been improving in notification delivery and now supports desktop notifications (for desktop browsers), and push notifications (for mobile/Android) out of the box. The older push plugin used to add this.

This plugin allows a user to allow push notifications on desktop. The difference is that push notifications can notify a user even when they have no browser tabs open.

If all of this sounded like gibberish and you’re still confused, the builtin notifications are probably all you need for notifications, and you don’t need to worry about plugins :wink:


(Michael Friedrich) #24

Hmmm, so if Discourse core now supports browser notifications on desktop as well as push notifications, I would need to remove the two plugins here?

I’m seeing endless notification popups when the browser tab is closed, reproducible with yesterday’s build, Chrome 66, macOS High Sierra. I haven’t dug any further into logs on why notifications are sent that often, but it may be related to a worker not clearing the queue and pushing a notification multiple times. Or the browser does foobar, I have to admit, browser notifications are a whole new thing for me, hard to debug.


(Jeff Wong) #25

Push notifications for desktop devices are not available in core. That’s what this plugin is for.

As for your issue, what do you mean by “endless” – screenshots or a video/gif would be nice here. Does it only happen when the browser tab is closed? Does it fix itself when you have a browser tab open?

Any reproduction steps would be good as well.

For an immediate fix, try toggling the live notification settings off and on again.


(Michael Friedrich) #26

Thanks for clarifying. Took me a bit to create a recording.

Versions involved

Recording

dnsmichi is my primary account, netmichi is just for testing.

Tests

The notification problem does not go away if you open the tab in the seconds the popups appear. This seems just to be asynchronous e.g. Discourse already pushed the notifications and Chrome displays them one after the other.

I’ve also tried to explicitly enable and disable “Prefer push notifications on desktop”, makes no difference.

When I explicitly disable “live notifications”, test again, and then enable them again, the problem vanishes.

Conclusion

I’ll keep watching it - the problem might only occur after a while and also be Chrome/macOS specific. Thanks for the help so far :slight_smile:


(Jeff Wong) #27

And you’re sure that the plugin version is up to date? It was a known bug in a previous version, but it’s been fixed, and I haven’t seen this since – Is it happening on meta as well?


(Michael Friedrich) #28

Tested a bit further with meta. On Fedora 28 with Chrome and Gnome, this works ootb. Similar thing with Chrome and macOS. So this really only affects/affected monitoring-portal.org - not sure if it is still the case after toggling live notifications and rebuilding the entire site, but I’ll watch further. Hopefully it magically resolved itself :slight_smile: