Skip to content

Commit 0e21bba

Browse files
committed
clarifications
1 parent 8626cf5 commit 0e21bba

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99

1010
If you have a PHP version smaller than 5.5.9, you will not be able to send any payload.
1111

12-
If you have a PHP version smaller than 7.1, you will have to `composer require spomky-labs/jose:2.0.x-dev`,
13-
and if you want to speed things up, install the [PHP Crypto](https://github.com/bukka/php-crypto) extension.
12+
If you have a PHP version smaller than 7.1, you will have to `composer require spomky-labs/jose:2.0.x-dev`.
1413

1514
## Usage
1615
WebPush can be used to send notifications to endpoints which server delivers web push notifications as described in
17-
the [Web Push API specification](http://www.w3.org/TR/push-api/).
16+
the [Web Push protocol](https://tools.ietf.org/html/draft-thomson-webpush-protocol-00).
1817
As it is standardized, you don't have to worry about what server type it relies on.
1918

19+
Notifications with payloads are supported with this library on Firefox 47+ and Chrome 50+.
20+
2021
```php
2122
<?php
2223

@@ -65,6 +66,12 @@ $webPush->sendNotification(
6566
);
6667
```
6768

69+
### Client side implementation of Web Push
70+
There are several good examples and tutorials on the web:
71+
* Mozilla's [ServiceWorker Cookbooks](https://serviceworke.rs/push-payload.html) (outdated as of 03-20-2016, because it does not take into account the user auth secret)
72+
* Google's [introduction to push notifications](https://developers.google.com/web/fundamentals/getting-started/push-notifications/) (as of 03-20-2016, it doesn't mention notifications with payload)
73+
* you may take a look at my own implementation: [sw.js](https://github.com/Minishlink/physbook/blob/07433bdb5fe4e3c7a6e4465c74e3b07c5a12886c/web/service-worker.js) and [app.js](https://github.com/Minishlink/physbook/blob/2a468273665a241ddc9aa2e12c57d18cd842d965/app/Resources/public/js/app.js) (payload sent indirectly)
74+
6875
### GCM servers notes (Chrome)
6976
For compatibility reasons, this library detects if the server is a GCM server and appropriately sends the notification.
7077

@@ -164,8 +171,11 @@ Feel free to add your own!
164171
Not until the [Push API spec](http://www.w3.org/TR/push-api/) is finished.
165172

166173
### What about security?
174+
Payload is encrypted according to the [Message Encryption for Web Push](https://tools.ietf.org/html/draft-ietf-webpush-encryption-01) standard,
175+
using the user public key and authentication secret that you can get by following the [Web Push API](http://www.w3.org/TR/push-api/) specification.
176+
167177
Internally, WebPush uses the [phpecc](https://github.com/phpecc/phpecc) Elliptic Curve Cryptography library to create
168-
local public and private keys and compute the shared secret.
178+
local public and private keys and compute the shared secret.
169179
Then, if you have a PHP >= 7.1, WebPush uses `openssl` in order to encrypt the payload with the encryption key.
170180
It uses [jose](https://github.com/Spomky-Labs/jose) if you have PHP < 7.1, which is slower.
171181

0 commit comments

Comments
 (0)