|
4 | 4 | [](https://travis-ci.org/web-push-libs/web-push-php)
|
5 | 5 | [](https://insight.sensiolabs.com/projects/d60e8eea-aea1-4739-8ce0-a3c3c12c6ccf)
|
6 | 6 |
|
| 7 | +WebPush can be used to send notifications to endpoints which server delivers Web Push notifications as described in |
| 8 | +the [Web Push protocol](https://tools.ietf.org/html/draft-thomson-webpush-protocol-00). |
| 9 | +As it is standardized, you don't have to worry about what server type it relies on. |
| 10 | + |
| 11 | +## Requirements |
| 12 | +* PHP 5.6 |
| 13 | + * gmp |
| 14 | + * mbstring |
| 15 | + * curl |
| 16 | + * openssl |
| 17 | + |
| 18 | +PHP 7.1 is recommended for better performance. |
| 19 | + |
7 | 20 | ## Installation
|
8 | 21 | Use [composer](https://getcomposer.org/) to download and install the library and its dependencies.
|
9 | 22 |
|
10 | 23 | `composer require minishlink/web-push`
|
11 | 24 |
|
12 | 25 | ## Usage
|
13 |
| -WebPush can be used to send notifications to endpoints which server delivers web push notifications as described in |
14 |
| -the [Web Push protocol](https://tools.ietf.org/html/draft-thomson-webpush-protocol-00). |
15 |
| -As it is standardized, you don't have to worry about what server type it relies on. |
16 |
| - |
17 |
| -Notifications with payloads are supported with this library on Firefox 46+ and Chrome 50+. |
18 |
| - |
19 |
| -You'll need at least PHP 5.6 with the following extensions enabled: gmp, mbstring, curl, openssl. |
20 |
| -PHP 7.1 is recommended for much better performance. |
21 |
| - |
22 | 26 | ```php
|
23 | 27 | <?php
|
24 | 28 |
|
@@ -176,6 +180,8 @@ $res = array(
|
176 | 180 | );
|
177 | 181 | ```
|
178 | 182 |
|
| 183 | +Firefox errors are listed in the [autopush documentation](https://autopush.readthedocs.io/en/latest/http.html#errors). |
| 184 | + |
179 | 185 | ### Payload length, security, and performance
|
180 | 186 | Payloads are encrypted by the library. The maximum payload length is theoretically 4078 bytes (or ASCII characters).
|
181 | 187 | For [compatibility reasons](mozilla-services/autopush/issues/748) though, your payload should be less than 3052 bytes long.
|
@@ -270,9 +276,18 @@ Make sure to require Composer's [autoloader](https://getcomposer.org/doc/01-basi
|
270 | 276 | require __DIR__ . '/path/to/vendor/autoload.php';
|
271 | 277 | ```
|
272 | 278 |
|
| 279 | +### I must use PHP 5.4 or 5.5. What can I do? |
| 280 | +You won't be able to send any payload, so you'll be only able to use `sendNotification($endpoint)`. |
| 281 | +Install the libray with `composer` using `--ignore-platform-reqs`. |
| 282 | +The workaround for getting the payload is to fetch it in the service worker ([example](https://github.com/Minishlink/physbook/blob/2ed8b9a8a217446c9747e9191a50d6312651125d/web/service-worker.js#L75)). |
| 283 | + |
273 | 284 | ### I lost my VAPID keys!
|
274 | 285 | See [issue #58](https://github.com/web-push-libs/web-push-php/issues/58).
|
275 | 286 |
|
| 287 | +### I'm using Firebase push notifications, how do I use this library? |
| 288 | +This library is not designed for Firebase push notifications. |
| 289 | +You can still use it for your web projects (for standard WebPush notifications), but you should forget any link to Firebase while using the library. |
| 290 | + |
276 | 291 | ### I need to send notifications to native apps. (eg. APNS for iOS)
|
277 | 292 | WebPush is for web apps.
|
278 | 293 | You need something like [RMSPushNotificationsBundle](https://github.com/richsage/RMSPushNotificationsBundle) (Symfony).
|
|
0 commit comments