Skip to content

Commit b1e9fb0

Browse files
committed
chore: update terminology from notifications to push messages
1 parent b1216d2 commit b1e9fb0

File tree

4 files changed

+41
-36
lines changed

4 files changed

+41
-36
lines changed

.github/CONTRIBUTING.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Feel free to contribute by submitting a pull request or creating (and solving) i
44

55
## Requirements before submitting a pull request
66

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 :
88

99
1. You fix web-push-testing-service completely, but it's very time consuming
1010
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
2828
alias web-push-testing-service='/usr/local/Cellar/node/7.4.0/bin/web-push-testing-service'
2929
```
3030

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.).
3432

3533
## Running Tests
3634

README.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ composer require minishlink/web-push
4141

4242
### Example
4343

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)
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)
4545

4646
### Send Push Message
4747

@@ -51,16 +51,16 @@ A complete example with html+JS frontend and php backend using `web-push-php` ca
5151
use Minishlink\WebPush\WebPush;
5252
use Minishlink\WebPush\Subscription;
5353

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.
5555
$subscription = Subscription::create(json_decode($clientSidePushSubscriptionJSON, true));
5656

57-
// array of notifications
58-
$notifications = [
57+
// Array of push messages.
58+
$messages = [
5959
[
6060
'subscription' => $subscription,
6161
'payload' => '{"message":"Hello World!"}',
6262
], [
63-
// current PushSubscription format (browsers might change this in the future)
63+
// Current PushSubscription format (browsers might change this in the future).
6464
'subscription' => Subscription::create([
6565
"endpoint" => "https://example.com/other/endpoint/of/another/vendor/abcdef...",
6666
"keys" => [
@@ -98,16 +98,16 @@ $notifications = [
9898

9999
$webPush = new WebPush();
100100

101-
// send multiple notifications with payload
102-
foreach ($notifications as $notification) {
101+
// Queue multiple push messages with payload.
102+
foreach ($messages as $message) {
103103
$webPush->queueNotification(
104-
$notification['subscription'],
105-
$notification['payload'] // optional (defaults null)
104+
$message['subscription'],
105+
$message['payload'] // optional (defaults null)
106106
);
107107
}
108108

109109
/**
110-
* Check sent results
110+
* Send all queued push messages and then check sent results.
111111
* @var MessageSentReport $report
112112
*/
113113
foreach ($webPush->flush() as $report) {
@@ -121,12 +121,12 @@ foreach ($webPush->flush() as $report) {
121121
}
122122

123123
/**
124-
* send one notification and flush directly
124+
* Send one push message and flush directly.
125125
* @var MessageSentReport $report
126126
*/
127127
$report = $webPush->sendOneNotification(
128-
$notifications[0]['subscription'],
129-
$notifications[0]['payload'], // optional (defaults null)
128+
$messages[0]['subscription'],
129+
$messages[0]['payload'], // optional (defaults null)
130130
);
131131
```
132132

@@ -181,7 +181,7 @@ $ openssl ec -in private_key.pem -outform DER|tail -c +8|head -c 32|base64|tr -d
181181
If you can't access a Linux bash, you can print the output of the `createVapidKeys` function:
182182

183183
```php
184-
var_dump(VAPID::createVapidKeys()); // store the keys afterwards
184+
var_dump(VAPID::createVapidKeys()); // Store the keys afterwards.
185185
```
186186

187187
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))
@@ -195,15 +195,15 @@ serviceWorkerRegistration.pushManager.subscribe({
195195

196196
#### Reusing VAPID headers
197197

198-
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:
198+
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:
199199

200200
```php
201201
$webPush->setReuseVAPIDHeaders(true);
202202
```
203203

204-
### Notifications and default options
204+
### Push message and default options
205205

206-
Each notification can have a specific Time To Live, urgency, and topic.
206+
Each push message can have a specific Time To Live, urgency, and topic.
207207
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.
208208
You can change the default options with `setDefaultOptions()` or in the constructor:
209209

@@ -220,19 +220,19 @@ $defaultOptions = [
220220
'contentType' => 'application/json', // defaults to "application/octet-stream"
221221
];
222222

223-
// for every notification
223+
// for every push messages
224224
$webPush = new WebPush([], $defaultOptions);
225225
$webPush->setDefaultOptions($defaultOptions);
226226

227-
// or for one notification
228227
$webPush->sendOneNotification($subscription, $payload, ['TTL' => 5000]);
228+
// or for one push message
229229
```
230230

231231
#### TTL
232232

233233
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
234-
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.
235-
However, if you send multiple nonessential notifications, set a TTL of 0: the push notification will be delivered only
234+
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.
235+
However, if you send multiple nonessential push messages, set a TTL of 0: the push message will be delivered only
236236
if the user is currently connected. For other cases, you should use a minimum of one day if your users have multiple time
237237
zones, and if they don't several hours will suffice.
238238

@@ -242,12 +242,12 @@ Urgency can be either "very-low", "low", "normal", or "high". If the browser ven
242242

243243
#### topic
244244

245-
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)).
245+
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)).
246246

247247
#### batchSize
248248

249-
If you send tens of thousands notifications at a time, you may get memory overflows due to how endpoints are called in Guzzle.
250-
In order to fix this, WebPush sends notifications in batches. The default size is 1000. Depending on your server configuration (memory), you may want
249+
If you send tens of thousands push messages at a time, you may get memory overflows due to how endpoints are called in Guzzle.
250+
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
251251
to decrease this number. Do this while instantiating WebPush or calling `setDefaultOptions`. Or, if you want to customize this for a specific flush, give
252252
it as a parameter : `$webPush->flush($batchSize)`.
253253

@@ -341,7 +341,7 @@ $webPush->setAutomaticPadding(true); // enable automatic padding to default maxi
341341
### Customizing the HTTP client
342342

343343
WebPush uses [Guzzle](https://github.com/guzzle/guzzle). It will use the most appropriate client it finds,
344-
and most of the time it will be `MultiCurl`, which allows to send multiple notifications in parallel.
344+
and most of the time it will be `MultiCurl`, which allows to send multiple push messages in parallel.
345345

346346
You can customize the default request options and timeout when instantiating WebPush:
347347

@@ -404,7 +404,7 @@ Make sure to require Composer's [autoloader](https://getcomposer.org/doc/01-basi
404404
require __DIR__ . '/path/to/vendor/autoload.php';
405405
```
406406

407-
### I get authentication errors when sending notifications
407+
### I get authentication errors when sending push messages
408408

409409
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.
410410

@@ -440,7 +440,7 @@ Use some alternative APIs like WebSocket/WebTransport or Background Synchronizat
440440
WebPush is for web apps.
441441
You need something like [RMSPushNotificationsBundle](https://github.com/richsage/RMSPushNotificationsBundle) (Symfony).
442442

443-
### This is PHP... I need Javascript!
443+
### This is PHP... I need JavaScript!
444444

445445
This library was inspired by the Node.js [web-push-libs/web-push](https://github.com/web-push-libs/web-push) library.
446446

@@ -464,6 +464,10 @@ This library was inspired by the Node.js [web-push-libs/web-push](https://github
464464

465465
- Working Draft [Push API](https://www.w3.org/TR/push-api/)
466466

467+
### WHATWG
468+
469+
- Living Standard [Notifications API](https://notifications.spec.whatwg.org/)
470+
467471
## License
468472

469473
[MIT](https://github.com/web-push-libs/web-push-php/blob/master/LICENSE)

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
"type": "library",
44
"description": "Web Push library for PHP",
55
"keywords": [
6-
"push",
76
"notifications",
7+
"push",
8+
"Push API",
9+
"RFC8030",
10+
"RFC8291",
11+
"RFC8292",
812
"web",
9-
"WebPush",
10-
"Push API"
13+
"WebPush"
1114
],
1215
"homepage": "https://github.com/web-push-libs/web-push-php",
1316
"license": "MIT",

src/Utils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public static function checkRequirementExtension(): void
6969
{
7070
$requiredExtensions = [
7171
'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.',
7474
];
7575
foreach ($requiredExtensions as $extension => $message) {
7676
if (!extension_loaded($extension)) {

0 commit comments

Comments
 (0)