peter.sh icon indicating copy to clipboard operation
peter.sh copied to clipboard

Web-Push-Javascript

Open lollita opened this issue 5 years ago • 1 comments

Web-Push-Php send webpush via php. I would to use client javascript to send webpush. Do I can to use this library to get it? How to have to set the value? in Web-Push-Php I have in server: vapid public.kye and private.key and when register I get: endpoint, publicKey, authToken, "contentEncoding":"aesgcm".

Do it is possible to use a hxr javascript instead of push.php?

lollita avatar Dec 29 '20 12:12 lollita

@lollita

Do I can to use this library to get it?

The https://tests.peter.sh/push.php doesn't so anything, it's just a CORS proxy to workaround CORS errors in the browser.

Do it is possible to use a hxr javascript instead of push.php?

I would to use client javascript to send webpush.

Some push services (e.g. https://fcm.googleapis.com/fcm/send/) don't allow CORS. So you can't make a network request to https://fcm.googleapis.com/fcm/send/ using fetch() directly from the browser. See https://github.com/w3c/push-api/issues/303.

In a normal situation (not for the demo purposes), to send a push message to the browser, you need to make a network request from your server, not the client.

If you use JS on the server, see https://github.com/web-push-libs/web-push npm package.

See also http://gauntface.github.io/simple-push-demo/ to understand better how to encrypt and send push messages.

FluorescentHallucinogen avatar Jul 28 '22 13:07 FluorescentHallucinogen