You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+71-21
Original file line number
Diff line number
Diff line change
@@ -9,45 +9,67 @@
9
9
10
10
## Usage
11
11
WebPush can be used to send notifications to endpoints which server delivers web push notifications as described in
12
-
the [Web Push API specification](http://www.w3.org/TR/push-api/).
12
+
the [Web Push protocol](https://tools.ietf.org/html/draft-thomson-webpush-protocol-00).
13
13
As it is standardized, you don't have to worry about what server type it relies on.
14
14
15
-
__*Currently, WebPush doesn't support payloads at all.
16
-
It is under development (see ["payload" branch](https://github.com/Minishlink/web-push/tree/payload)).
17
-
PHP 7.1 will be needed for some encryption features.*__
18
-
Development of payload support is stopped until [this PHP bug](https://bugs.php.net/bug.php?id=67304) is fixed.
19
-
If you need to show custom info in your notifications, you will have to fetch this info from your server in your Service
20
-
Worker when displaying the notification (see [this example](https://github.com/Minishlink/physbook/blob/e98ac7c3b7dd346eee1f315b8723060e8a3fc5cb/web/service-worker.js#L75)).
15
+
Notifications with payloads are supported with this library on Firefox 46+ and Chrome 50+.
There are several good examples and tutorials on the web:
67
+
* 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)
68
+
* 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)
69
+
* 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)
70
+
46
71
### GCM servers notes (Chrome)
47
72
For compatibility reasons, this library detects if the server is a GCM server and appropriately sends the notification.
48
-
GCM servers don't support encrypted payloads yet so WebPush will skip the payload.
49
-
If you still want to show that payload on your notification, you should get that data on client-side from your server
50
-
where you will have to store somewhere the history of notifications.
51
73
52
74
You will need to specify your GCM api key when instantiating WebPush:
0 commit comments