-1

I have tried to add Chrome Desktop notification to my website. I have followed this:

Chrome desktop notification example

and I have added the script code to my website and it work fine with me, but I have a problem.

When I click on "notify" button the notification just appears to me, but I want the notification be shown to all users who granted the permission.

Can anyone help me please?

Community
  • 1
  • 1
Eng Ali
  • 13
  • 5

1 Answers1

0

You're looking at wrong documentation - or rather, only one part of it. There are separate problems of displaying the notification (which you solved) and delivering it to others (which you didn't, and alarmingly didn't understand that it's missing).

You have to code the show a local notification, but there's nothing to actually send out (push) the message or receive it. In short, there's still a lot of work to be done.

What you need is the Push API. It involves creating a Service Worker for your site (which will be the part able to listen to push messages) and having server-side code that talks to Google Cloud Messaging to generate a push. There's a good tutorial on how to use it.

Xan
  • 74,770
  • 16
  • 179
  • 206