@@ -9,24 +9,41 @@ WebPush can be used to send notifications to endpoints which server delivers web
9
9
the [ Web Push API specification] ( http://www.w3.org/TR/push-api/ ) .
10
10
As it is standardized, you don't have to worry about what server type it relies on.
11
11
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
-
15
12
``` php
16
13
<?php
17
14
18
15
use Minishlink\WebPush\WebPush;
19
16
20
17
// array of endpoints
21
18
$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',
25
39
);
26
40
27
41
$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
30
47
```
31
48
32
49
### GCM servers notes (Chrome)
@@ -82,6 +99,9 @@ $browser = $webPush->getBrowser();
82
99
### Is the API stable?
83
100
Not until the [ Push API spec] ( http://www.w3.org/TR/push-api/ ) is finished.
84
101
102
+ ### What about security?
103
+ Internally, WebPush uses the [ phpecc] ( https://github.com/phpecc/phpecc ) Elliptic Curve Cryptography library.
104
+
85
105
### How to solve "SSL certificate problem: unable to get local issuer certificate" ?
86
106
Your installation lacks some certificates.
87
107
0 commit comments