web-push-php icon indicating copy to clipboard operation
web-push-php copied to clipboard

Make sound in the push notification. Does anyone know how to issue push notification?

Open marcosmarf27 opened this issue 4 years ago • 1 comments

Make sound in the push notification.

Does anyone know how to issue push notification?

marcosmarf27 avatar Feb 03 '21 19:02 marcosmarf27

I've been researching this as well and even emailed some of the contributors but nothing has come up as yet.

8Ozymandias avatar Mar 11 '21 22:03 8Ozymandias

Service Workers, for now, do not support playing of sounds. Below is the workaround I use.

In my Service Worker, when I receive the push (when the push event is fired), I post a message (instructing to play notification sound) to any open window/client being controlled by the service worker. Then, on the app side, I have a listener that should receive the posted message from the service worker. Once the message is received, I check the instruction from the service worker (I have several other kinds of instructions for other things/actions though). If the instruction is to play notification sound, I then play it from the open window (app).

Limitation: it works only when a window of your site/app is already open before the push arrives.

preciousfocus avatar Mar 06 '24 07:03 preciousfocus