Skip to content

Commit d099062

Browse files
committed
update readme for payload support
1 parent ad00c88 commit d099062

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

README.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,41 @@ WebPush can be used to send notifications to endpoints which server delivers web
99
the [Web Push API specification](http://www.w3.org/TR/push-api/).
1010
As it is standardized, you don't have to worry about what server type it relies on.
1111

12-
__*Currently, WebPush doesn't support payloads at all.
13-
It is under development (see ["payload" branch](https://github.com/Minishlink/web-push/tree/payload)).*__
14-
1512
```php
1613
<?php
1714

1815
use Minishlink\WebPush\WebPush;
1916

2017
// array of endpoints
2118
$endpoints = array(
22-
'https://android.googleapis.com/gcm/send/abcdef...', // Chrome
23-
'https://updates.push.services.mozilla.com/push/adcdef...', // Firefox 43+
24-
'https://example.com/other/endpoint/of/another/vendor/abcdef...',
19+
'https://updates.push.services.mozilla.com/push/abc...', // Firefox 43+
20+
'https://updates.push.services.mozilla.com/push/def...',
21+
'https://example.com/other/endpoint/of/another/vendor/abc...',
22+
'https://example.com/other/endpoint/of/another/vendor/abc...',
23+
);
24+
25+
// array of payloads which are strings or null (json_encode your arrays)
26+
$payloads = array(
27+
'hello !',
28+
'{'msg': 'test'}',
29+
null,
30+
'',
31+
);
32+
33+
// array of the public keys of each users
34+
$userPublicKeys = array(
35+
'thePublicKeysCorrespondingToFirstEndpoint',
36+
'thePublicKeysCorrespondingToSecondEndpoint',
37+
'thePublicKeysCorrespondingToThirdEndpoint',
38+
'thePublicKeysCorrespondingToFourthEndpoint',
2539
);
2640

2741
$webPush = new WebPush();
28-
$webPush->sendNotification($endpoints[0]); // send one notification
29-
$webPush->sendNotifications($endpoints); // send multiple notifications
42+
$webPush->sendNotification($endpoints[0]); // send one notification without payload
43+
$webPush->sendNotifications($endpoints); // send multiple notifications without payloads
44+
45+
$webPush->sendNotification($endpoints[0], $payloads[0], $userPublicKeys[0]); // send one notification with payload
46+
$webPush->sendNotifications($endpoints, $payloads, $userPublicKeys); // send multiple notifications with payloads
3047
```
3148

3249
### GCM servers notes (Chrome)
@@ -82,6 +99,9 @@ $browser = $webPush->getBrowser();
8299
### Is the API stable?
83100
Not until the [Push API spec](http://www.w3.org/TR/push-api/) is finished.
84101

102+
### What about security?
103+
Internally, WebPush uses the [phpecc](https://github.com/phpecc/phpecc) Elliptic Curve Cryptography library.
104+
85105
### How to solve "SSL certificate problem: unable to get local issuer certificate" ?
86106
Your installation lacks some certificates.
87107

0 commit comments

Comments
 (0)