# 有新通知权限请求栏？

**URL:** https://meta.discourse.org/t/new-notification-permissions-request-bar/85043
**Category:** UX
**Created:** [2018年四月11日 02:00 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043 "2018-04-11T02:00:22Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2018年四月11日 02:00 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/1 "2018-04-11T02:00:23Z")

</div>

What’s up with this blaring blue bar?

 ![59%20PM](https://global.discourse-cdn.com/meta/original/3X/b/3/b3dcb517ce6df6db74d7eb59c889e1ab2c4c087a.png)

Just hopped on a new computer and I don’t remember seeing this before; and can’t see any recent Meta topics about adding it.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2018年四月11日 02:03 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/2 "2018-04-11T02:03:37Z")

</div>

It’s an option (default off) from the push notifications plugin. We are testing it on Meta right now.

Here is the announcement:

[https://meta.discourse.org/t/discourse-push-notifications/46692/236?u=falco](https://meta.discourse.org/t/discourse-push-notifications/46692/236)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2018年四月11日 04:50 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/3 "2018-04-11T04:50:19Z")

</div>

What is the difference between Desktop Notifications and Push Notifications? This is kinda confusing:

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/8/08e98e1f2a13307b3398d57a1749c0fc5b769db5.png)

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2018年四月11日 05:31 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/4 "2018-04-11T05:31:26Z")

</div>

Yeah that should be simplified for the user…

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2018年四月11日 20:30 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/5 "2018-04-11T20:30:14Z")

</div>

My vote here is to add `discourse-push-notifications` to core and remove “Desktop Notifications” altogether.

Anyone know any use case that we would break by doing that?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2018年四月11日 20:45 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/6 "2018-04-11T20:45:10Z")

</div>

This does not answer my question, what is the difference between the two? Very confused right now 😖

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2018年四月11日 20:48 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/7 "2018-04-11T20:48:39Z")

</div>

Desktop notifications: only works when you are browsing the site (ie: with a tab open)

Push Notifications: always work.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2018年四月11日 20:50 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/8 "2018-04-11T20:50:35Z")

</div>

One thing is Desktop displays the site logo and AFAIK only new posts, while Push displayed the reply icon.

Off-topic, does the mobile app notifications touch the same code?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2018年四月11日 21:00 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/9 "2018-04-11T21:00:55Z")

</div>

~~Also, the push notifications plugin requires a Google app registration (on Chrome), while “desktop notifications” work without that - but only when the forum is open.~~

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2018年四月11日 21:04 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/10 "2018-04-11T21:04:44Z")

</div>

> [@riking](#):
>
> the push notifications plugin requires a Google app registration (on Chrome)

They don’t require that anymore. Both Chrome and Firefox implement [VAPID](https://tools.ietf.org/html/draft-ietf-webpush-vapid-01).

> **[Web Push Interoperability Wins  |  Blog  |  Chrome for Developers](https://developer.chrome.com/blog/web-push-interop-wins)**
>
> Web push has had a few updates in recent versions of Chrome. GCM now supports the web push protocol and if you use VAPID you won't need to sign up for a Google Developer Project and you'll be given an FCM endpoint.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2018年四月11日 21:08 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/11 "2018-04-11T21:08:08Z")

</div>

Oh, then there’s no reason to have the old desktop notifications implementation!

In that case, I support moving push notifications to default / core and removing the old version.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2018年四月11日 21:09 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/12 "2018-04-11T21:09:24Z")

</div>

> [@riking](#):
>
> Oh, then there’s no reason to have the old desktop notifications implementation!

🎉

> [@riking](#):
>
> In that case, I support moving push notifications to default / core and removing the old version.

😍

I really think it would help a lot having this out of the box on Discourse everywhere now that the setup is so simple.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2018年四月12日 02:33 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/13 "2018-04-12T02:33:49Z")

</div>

Sure go for it.. two settings is super weird.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2018年四月12日 02:36 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/14 "2018-04-12T02:36:55Z")

</div>

> [@riking](#):
>
> Oh, then there’s no reason to have the old desktop notifications implementation!

Wow, even works on the [edge](https://blog.pushpad.xyz/2017/12/microsoft-edge-now-supports-web-push-notifications/) case.

Also, I am very disappointed in how long it has taken me to come up with edge puns.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2018年四月12日 04:16 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/15 "2018-04-12T04:16:55Z")

</div>

> [@codinghorror](#):
>
> This does not answer my question, what is the difference between the two?

Desktop notification and Push Notification are just two different implementations of showing a native notification on the device.

The [desktop notification](https://meta.discourse.org/t/show-desktop-notifications-when-available/10183) feature was implemented by having the clients subscribe to a `messageBus` channel and it uses the browser’s [Web Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/notification) to display a notification on the user’s desktop. When the tab is closed, it kills the messageBus subscription which is why the user would stop getting the native notification. This feature works across all the major desktop browser.

 ![Screenshot%20from%202018-04-12%2011-55-49](https://global.discourse-cdn.com/meta/original/3X/9/2/926aeb61046386b9964514ecf438e41f4ec7a60e.png)

Push Notification on the other hand requires the client to have a service worker registered. When the client enables push notification, it uses the service worker API to create a `pushManager` subscription [which is sent and stored on the server](https://github.com/discourse/discourse-push-notifications/blob/e8db93aeb60115b407d229082373d6c6d24ac375/assets/javascripts/discourse/lib/push-notifications.js.es6#L53). That subscription object contains a `unique` (I think) endpoint to a push service and the encryption keys that are used to encrypt the payload.

> Browsers that support web push each implement their own push service, which is a system for processing messages and routing them to the correct clients. Push messages destined to become notifications are sent from a server directly to the push service, and contain the information necessary for the push service to send it to the right client and wake up the correct service worker.

Currently one service worker can be registered per domain and that service worker runs in the background even if all the tabs to a site are closed. This is why we’re still able to display native notification even when all the tabs are closed.

When a notification is created in Discourse, we basically add a callback that would sent a payload to the respective browser’s push service which then does its magic on routing the payload to the client. Currently, only Safari lacks support for the Push API which I think may be coming soon since service workers have already been implemented in latest version.

 ![Screenshot%20from%202018-04-12%2012-11-26](https://global.discourse-cdn.com/meta/original/3X/f/2/f2daef906cbc99b169a14ab46545753e74857fe8.png)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2018年四月12日 04:35 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/16 "2018-04-12T04:35:21Z")

</div>

> [@Falco](#):
>
> My vote here is to add discourse-push-notifications to core and remove “Desktop Notifications” altogether.

I would hold off on this until we are able to support push on all the 4 major browsers. What I think we should do while waiting is to not show the `Desktop Notifications` button if `Push Notifications` is available in the browser.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2018年四月12日 04:38 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/17 "2018-04-12T04:38:49Z")

</div>

I would rather rip off the band-aid and do this now. Having duplicate code and UI for basically identical features is a nightmare.

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [2018年四月12日 05:04 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/18 "2018-04-12T05:04:32Z")

</div>

I also want to squelch notifications when a page is actively focused on. This is something in the desktop notifications that is not yet in the push plugin.

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [2018年四月13日 00:45 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/19 "2018-04-13T00:45:33Z")

</div>

Until push notifications are included in core, I’d prefer to not to do anything that drastic. In the meantime, can anyone tell me if there is a better way of disabling portions of the UI from displaying?

[https://github.com/discourse/discourse/pull/5759](https://github.com/discourse/discourse/pull/5759)

This exposes an option that can be called to disable/remove the desktop notifications from the UI. I’ve got a feature branch I’m working on in push notifications to consume it.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2018年四月13日 00:57 UTC](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043/20 "2018-04-13T00:57:02Z")

</div>

I am with @codinghorror here, its mega weird to have 2 different implementations of a feature. Especially when the plugin way is the “correct way” of doing things.

My call here it to just deal with the pain and replace the old way with the new way and get rid of the plugin.

[下一頁](https://meta.discourse.org/t/new-notification-permissions-request-bar/85043.md?page=2)
