Discourse Push Notifications for Desktop

Because you get “desktop” notifications out-of-the-box, so the need to get notifications WHILE chrome has zero tabs navigated to the Discourse site is considered an edge case and anti feature to some people.

4 Likes

Is there a way to have notifications show up by default, or somehow have the user grant permission without going into their Settings? They may not dig into it but most people would like to know when someone replied to their message.

Can not be done, users must explicitly allow this feature, that is a browser restriction, nothing we have control over.

Otherwise you would navigate to a bunch of sites and suddenly … pop up central would start to happen.

4 Likes

If “discoverability” of the feature is your main concern, you can turn the setting push notifications prompt so users will be prompted to enable push notifications when they first post.

4 Likes

Discourse has a feature which shows push notifications already on Desktop also.

image

  • Should I still consider using this plugin? :confused:

Read this:

If you want notifications from your site in desktop while nobody is navigated to your site to work, consider using this plugin.

Facebook do this, for example, out-of-the-box and it is horrendous.

5 Likes

Everything is awesome. I have one little concern that we shouldn’t receive continuous a push notification for already read messages.

1 Like

Trying to get this going. The first time I enabled in my admin profile, I believe I saw a 403 error. Subsequent times I can enable OK (at least no error), but when the page is reloaded the option has been disabled again. Am I missing something? Thanks!

Isn’t this enabled by default on the latest Discourse version?
Or should we install this plugin separately even if we are on the latest version of Discourse?

1 Like

I’ve enabled push notifications on my discourse forum (as an admin).
And I’ve accepted the chrome prompt in Android mobile to receive my forum notifs.

Yet, neither I receive any live/push notifs while I’m sitting on pc/browsing thru Firefox (doesn’t matter if my forum is open in some tab or not).
Nor do I receive any type of notif in my android mobile. Am I missing something?

every forum user browsing my forum on Android mobile Chrome browser gets a prompt to enable push notifications, which he does, and accepts the prompt, yet no notif.

I’ve enabled ‘Push Notifs Plugin’ as shown below.

But I still get push/live notifs on desktop ONLY when the forum is open in some/one tab. If I close my forum from all tabs of my browser/firefox latest version, no notif would be received.

And, as discussed in previous post, on mobile no notif is received ever (even though Android Chrome is correctly configured to send/receive push notifs for this/my forum).

1 Like

Yes, this is the same behavior I’ve long observed. No push notifications unless the forum is open on a tab.

1 Like

@BobbyZopfan @L30110 after you toggle the checkmark for prefering push notification, you need to re-enable notifications.

3 Likes

I’ve already tried doing that. Enabling, disabling, then enabling again.
But on PC, Notifs arrive only if forum is open in some tab. Whether Notifs plugin installed or not. (I highly doubt if the plugin is needed at all, after the Notifs is part of core now)

On mobile, notifs arrive only on Nokia mobile.

It for sure seems the checkbox isn’t saving (even when I hit save). Doesn’t matter if notifications were enabled or disabled. Checking the box, saving and refreshing shows it unchecked. If notifications are disabled and the box is checked, the enable notifications button can be clicked but nothing happens. The button stays the same and I don’t get a notification.Just installed the plugin a few minutes ago. Sure seems like this plugin is broken @featheredtoast

EDIT: Seems that the LocalStorage key discourse_push_notifications_prefer_push is getting wiped out on every refresh. Possibly related.

EDIT 2: My amateur Discourse development skills have led me to believe the custom user field isn’t being set with the users preference choice. LocalStorage key is being reset to "" because it doesn’t match what custom field has stored. Looks like this may have been introduced at 775a4c81b9dcb424243af64a61b0a7a6c81606b8 by @tgxworld. Feel free to signup at the Home Assistant Forums to see for yourselves.

For what it’s worth in terms of diagnosing this, desktop push notifications when the forum is not open in a browser tab have very recently started working for my forum here.

Okay, dug in even more. Set the custom user field using the Rails console directly. The checkbox now works (meaning its stuck on and the local storage key isn’t being reset on reload anymore, but I can’t toggle the box still). However, Chrome won’t register itself still. Neither will Firefox. I’m on Mac. I booted up my Pixel 3 and it registered fine. I am confirming that registration has(n’t) happened by using the Rails console to check all PushSubscription's for my user ID. I saw the Android registration pop up, but not the Chrome or Firefox registrations.

I figured it out!!

I’m on a Mac running Chrome. I realized the required service worker wasn’t ever being registered. It took me a while to figure it out, but eventually I found a recent comment from @sam here saying the service worker is disabled on any Apple devices. I set a breakpoint before the check is done and faked out the navigator.platform property (thanks to this StackOverflow post for the tip!) like so:

var fakePlatformGetter = function () {
  return "Windows";
};
if (Object.defineProperty) {
  Object.defineProperty(navigator, "platform", {
    get: fakePlatformGetter
  });
} else if (Object.prototype.__defineGetter__) {
  navigator.__defineGetter__("platform", fakePlatformGetter);
}

Continue running, service worker was registered fine and the entire UI, saving the checkbox, everything, started working just fine.

It seems the service worker was disabled on all Apple platforms (over a year ago I might add) due to it not being used for any features & service workers causing problems. Obviously now we do need to use the service worker on Apple platform (at least Mac) to be able to receive push notifications.

I’ve gone ahead and submitted a PR to re-enable the service worker on Apple platforms. Will be glad to see this merged soon so that I and others can finally have push notifications!!

There were boatloads of customer support issues with this in the past (in Safari), so it is unlikely we are just going to flip it back on.

That’s fair and good feedback. I’m more than happy to rewrite the conditional to block out all browsers except Chrome and Safari on Mac. Would that be acceptable?