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: .github/CONTRIBUTING.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Feel free to contribute by submitting a pull request or creating (and solving) i
4
4
5
5
## Requirements before submitting a pull request
6
6
7
-
The CI used to check that push notifications can still be sent after the proposed code changes thanks to [web-push testing service](https://www.npmjs.com/package/web-push-testing-service). Unfortunately, this package doesn't work anymore and I don't have the available time to fix it. We can't accept new PR without being sure that the code changes doesn't break anything. So, for a PR to be accepted, it is now requested to have one of these 3 solutions :
7
+
The CI used to check that push messages can still be sent after the proposed code changes thanks to [web-push testing service](https://www.npmjs.com/package/web-push-testing-service). Unfortunately, this package doesn't work anymore and I don't have the available time to fix it. We can't accept new PR without being sure that the code changes doesn't break anything. So, for a PR to be accepted, it is now requested to have one of these 3 solutions :
8
8
9
9
1. You fix web-push-testing-service completely, but it's very time consuming
10
10
2. You fix web-push-testing-service but only for stable version of Chrome, looks a bit more promising but still you'll need some time
@@ -28,9 +28,7 @@ NOTE: You might need to make sure command `web-push-testing-service` runs OK on
28
28
alias web-push-testing-service='/usr/local/Cellar/node/7.4.0/bin/web-push-testing-service'
29
29
```
30
30
31
-
After that, please create your own configuration file by copying
32
-
`phpunit.dist.xml` to phpunit.xml and filling in the fields you need for
33
-
testing (i.e. STANDARD_ENDPOINT, etc.).
31
+
After that, please create your own configuration file by copying `phpunit.dist.xml` to phpunit.xml and filling in the fields you need for testing (i.e. STANDARD_ENDPOINT, etc.).
A complete example with html+JS frontend and php backend using `web-push-php` can be found here: [Minishlink/web-push-php-example](https://github.com/Minishlink/web-push-php-example)
44
+
A complete example with HTML+JS frontend and php backend using `web-push-php` can be found here: [Minishlink/web-push-php-example](https://github.com/Minishlink/web-push-php-example)
45
45
46
46
### Send Push Message
47
47
@@ -51,16 +51,16 @@ A complete example with html+JS frontend and php backend using `web-push-php` ca
51
51
use Minishlink\WebPush\WebPush;
52
52
use Minishlink\WebPush\Subscription;
53
53
54
-
// store the client-side `PushSubscription` object (calling `.toJSON` on it) as-is and then create a WebPush\Subscription from it
54
+
// Store the client-side `PushSubscription` object (calling `.toJSON` on it) as-is and then create a WebPush\Subscription from it.
If you can't access a Linux bash, you can print the output of the `createVapidKeys` function:
169
169
170
170
```php
171
-
var_dump(VAPID::createVapidKeys()); // store the keys afterwards
171
+
var_dump(VAPID::createVapidKeys()); // Store the keys afterwards.
172
172
```
173
173
174
174
On the client-side, don't forget to subscribe with the VAPID public key as the `applicationServerKey`: (`urlBase64ToUint8Array` source [here](https://github.com/Minishlink/physbook/blob/02a0d5d7ca0d5d2cc6d308a3a9b81244c63b3f14/app/Resources/public/js/app.js#L177))
VAPID headers make use of a JSON Web Token (JWT) to verify your identity. That token payload includes the protocol and hostname of the endpoint included in the subscription and an expiration timestamp (usually between 12-24h), and it's signed using your public and private key. Given that, two notifications sent to the same push service will use the same token, so you can reuse them for the same flush session to boost performance using:
185
+
VAPID headers make use of a JSON Web Token (JWT) to verify your identity. That token payload includes the protocol and hostname of the endpoint included in the subscription and an expiration timestamp (usually between 12-24h), and it's signed using your public and private key. Given that, two push messages sent to the same push service will use the same token, so you can reuse them for the same flush session to boost performance using:
186
186
187
187
```php
188
188
$webPush->setReuseVAPIDHeaders(true);
189
189
```
190
190
191
-
### Notifications and default options
191
+
### Push message and default options
192
192
193
-
Each notification can have a specific Time To Live, urgency, and topic.
193
+
Each push message can have a specific Time To Live, urgency, and topic.
194
194
The WebPush standard states that `urgency` is optional but some users reports that Safari throws errors when it is not specified. This might be fixed in the future.
195
195
You can change the default options with `setDefaultOptions()` or in the constructor:
196
196
@@ -207,19 +207,19 @@ $defaultOptions = [
207
207
'contentType' => 'application/json', // defaults to "application/octet-stream"
Time To Live (TTL, in seconds) is how long a push message is retained by the push service (eg. Mozilla) in case the user browser
221
-
is not yet accessible (eg. is not connected). You may want to use a very long time for important notifications. The default TTL is 4 weeks.
222
-
However, if you send multiple nonessential notifications, set a TTL of 0: the push notification will be delivered only
221
+
is not yet accessible (eg. is not connected). You may want to use a very long time for important push messages. The default TTL is 4 weeks.
222
+
However, if you send multiple nonessential push messages, set a TTL of 0: the push message will be delivered only
223
223
if the user is currently connected. For other cases, you should use a minimum of one day if your users have multiple time
224
224
zones, and if they don't several hours will suffice.
225
225
@@ -229,12 +229,12 @@ Urgency can be either "very-low", "low", "normal", or "high". If the browser ven
229
229
230
230
#### topic
231
231
232
-
This string will make the vendor show to the user only the last notification of this topic (cf. [protocol](https://datatracker.ietf.org/doc/html/rfc8030#section-5.4)).
232
+
This string will make the vendor show to the user only the last message of this topic (cf. [protocol](https://datatracker.ietf.org/doc/html/rfc8030#section-5.4)).
233
233
234
234
#### batchSize
235
235
236
-
If you send tens of thousands notifications at a time, you may get memory overflows due to how endpoints are called in Guzzle.
237
-
In order to fix this, WebPush sends notifications in batches. The default size is 1000. Depending on your server configuration (memory), you may want
236
+
If you send tens of thousands push messages at a time, you may get memory overflows due to how endpoints are called in Guzzle.
237
+
In order to fix this, WebPush sends push messages in batches. The default size is 1000. Depending on your server configuration (memory), you may want
238
238
to decrease this number. Do this while instantiating WebPush or calling `setDefaultOptions`. Or, if you want to customize this for a specific flush, give
239
239
it as a parameter : `$webPush->flush($batchSize)`.
WebPush uses [Guzzle](https://github.com/guzzle/guzzle). It will use the most appropriate client it finds,
331
-
and most of the time it will be `MultiCurl`, which allows to send multiple notifications in parallel.
331
+
and most of the time it will be `MultiCurl`, which allows to send multiple push messages in parallel.
332
332
333
333
You can customize the default request options and timeout when instantiating WebPush:
334
334
@@ -391,7 +391,7 @@ Make sure to require Composer's [autoloader](https://getcomposer.org/doc/01-basi
391
391
require __DIR__ . '/path/to/vendor/autoload.php';
392
392
```
393
393
394
-
### I get authentication errors when sending notifications
394
+
### I get authentication errors when sending push messages
395
395
396
396
Make sure to have database fields that are large enough for the length of the data you are storing ([#233](https://github.com/web-push-libs/web-push-php/issues/233#issuecomment-1252617883)). For the endpoint, users have reported that the URL length does not exceed 500 characters, but this can evolve so you can set it to the 2048 characters limit of most browsers.
397
397
@@ -427,7 +427,7 @@ Use some alternative APIs like WebSocket/WebTransport or Background Synchronizat
427
427
WebPush is for web apps.
428
428
You need something like [RMSPushNotificationsBundle](https://github.com/richsage/RMSPushNotificationsBundle) (Symfony).
429
429
430
-
### This is PHP... I need Javascript!
430
+
### This is PHP... I need JavaScript!
431
431
432
432
This library was inspired by the Node.js [web-push-libs/web-push](https://github.com/web-push-libs/web-push) library.
433
433
@@ -451,6 +451,10 @@ This library was inspired by the Node.js [web-push-libs/web-push](https://github
451
451
452
452
- Working Draft [Push API](https://www.w3.org/TR/push-api/)
453
453
454
+
### WHATWG
455
+
456
+
- Living Standard [Notifications API](https://notifications.spec.whatwg.org/)
Copy file name to clipboardExpand all lines: src/Utils.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -69,8 +69,8 @@ public static function checkRequirementExtension(): void
69
69
{
70
70
$requiredExtensions = [
71
71
'curl' => '[WebPush] curl extension is not loaded but is required. You can fix this in your php.ini.',
72
-
'mbstring' => '[WebPush] mbstring extension is not loaded but is required for sending push notifications with payload or for VAPID authentication. You can fix this in your php.ini.',
73
-
'openssl' => '[WebPush] openssl extension is not loaded but is required for sending push notifications with payload or for VAPID authentication. You can fix this in your php.ini.',
72
+
'mbstring' => '[WebPush] mbstring extension is not loaded but is required for sending push messages with payload or for VAPID authentication. You can fix this in your php.ini.',
73
+
'openssl' => '[WebPush] openssl extension is not loaded but is required for sending push messages with payload or for VAPID authentication. You can fix this in your php.ini.',
0 commit comments