Skip to content

Commit fe142fa

Browse files
committed
chore: update terminology from notifications to push messages
1 parent a368e42 commit fe142fa

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

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

170170
```php
171-
var_dump(VAPID::createVapidKeys()); // store the keys afterwards
171+
var_dump(VAPID::createVapidKeys()); // Store the keys afterwards.
172172
```
173173

174174
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))
@@ -182,15 +182,15 @@ serviceWorkerRegistration.pushManager.subscribe({
182182

183183
#### Reusing VAPID headers
184184

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

187187
```php
188188
$webPush->setReuseVAPIDHeaders(true);
189189
```
190190

191-
### Notifications and default options
191+
### Push message and default options
192192

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.
194194
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.
195195
You can change the default options with `setDefaultOptions()` or in the constructor:
196196

@@ -207,19 +207,19 @@ $defaultOptions = [
207207
'contentType' => 'application/json', // defaults to "application/octet-stream"
208208
];
209209

210-
// for every notification
210+
// for every push messages
211211
$webPush = new WebPush([], $defaultOptions);
212212
$webPush->setDefaultOptions($defaultOptions);
213213

214-
// or for one notification
215214
$webPush->sendOneNotification($subscription, $payload, ['TTL' => 5000]);
215+
// or for one push message
216216
```
217217

218218
#### TTL
219219

220220
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
223223
if the user is currently connected. For other cases, you should use a minimum of one day if your users have multiple time
224224
zones, and if they don't several hours will suffice.
225225

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

230230
#### topic
231231

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

234234
#### batchSize
235235

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
238238
to decrease this number. Do this while instantiating WebPush or calling `setDefaultOptions`. Or, if you want to customize this for a specific flush, give
239239
it as a parameter : `$webPush->flush($batchSize)`.
240240

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

330330
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.
332332

333333
You can customize the default request options and timeout when instantiating WebPush:
334334

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

394-
### I get authentication errors when sending notifications
394+
### I get authentication errors when sending push messages
395395

396396
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.
397397

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

430-
### This is PHP... I need Javascript!
430+
### This is PHP... I need JavaScript!
431431

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

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

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

454+
### WHATWG
455+
456+
- Living Standard [Notifications API](https://notifications.spec.whatwg.org/)
457+
454458
## License
455459

456460
[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)