beverloo / peter.sh

Source-code for http://peter.sh/.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Web-Push-Javascript

lollita opened this issue · 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

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 w3c/push-api#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.