electron: serviceWorkerRegistration.showNotification does not work

  • Electron Version: 1.8.x - 2.x
  • Operating System (Platform and Version): Win, Linux, MacOSX
  • Last known working Electron version: no

Expected Behavior notification should be shown

Actual behavior notification not shown

To Reproduce here example: https://github.com/dregenor/showNotification.git

  1. clone,
  2. npm install,
  3. npm start click “Show Notification”
$ git clone https://github.com/dregenor/showNotification.git -b master
$ npm install
$ npm start

in browser all works fine. example:

  1. open src folder and start simpleHttp server
python -m SimpleHTTPServer 8080
  1. open in Google Chrome http://127.0.0.1:8080
  2. press “Show Notification” button

result: image

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 9
  • Comments: 15 (1 by maintainers)

Most upvoted comments

is there any update on this please?

Still the same in Electron v11.1.1

I’d love it if this was implemented.

It’d mean I’d be able to create notifications with buttons which you can only do from a service worker.

Same behavior with Electron v9.0.4.

Any update or a possible ETA ?

Still would love to see this! I might give it a go, but I don’t expect to get far, since I don’t know any C++, nor have any experience with Chromium development. Since this is implemented in Chromium, I am hoping that some elaborate copy&pasta might be enough.

Is there a way we can add a shim that will override this and forward the notification to the regular Notification api?

👍 please electron team, add this api

One of the most basic and most critical features. Not possible to create serious apps otherwise.

Please implement this! We have to drop election otherwise.

Electron doesn’t currently support persistent notifications. We would consider PRs that added support, but have no plans to work on it in the immediate future.

See e.g. https://github.com/electron/electron/blob/fd0eaf4507835d38b0ab979f1db1118ea4cc529e/shell/browser/notifications/platform_notification_service.cc#L134