Skip to content

Commit 0d0ed77

Browse files
committed
Update README
1 parent 1d39285 commit 0d0ed77

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ serviceWorkerRegistration.pushManager.subscribe({
123123
})
124124
```
125125

126-
### Notification options
126+
### Notifications and default options
127127
Each notification can have a specific Time To Live, urgency, and topic.
128128
You can change the default options with `setDefaultOptions()` or in the constructor:
129129

@@ -135,7 +135,8 @@ use Minishlink\WebPush\WebPush;
135135
$defaultOptions = array(
136136
'TTL' => 300, // defaults to 4 weeks
137137
'urgency' => 'normal', // protocol defaults to "normal"
138-
'topic' => 'new_event', // not defined by default
138+
'topic' => 'new_event', // not defined by default,
139+
'batchSize' => 200, // defaults to 1000
139140
);
140141

141142
// for every notifications
@@ -159,6 +160,12 @@ Urgency can be either "very-low", "low", "normal", or "high". If the browser ven
159160
#### topic
160161
Similar to the old `collapse_key` on legacy GCM servers, this string will make the vendor show to the user only the last notification of this topic (cf. [protocol](https://tools.ietf.org/html/draft-ietf-webpush-protocol-08#section-5.4)).
161162

163+
#### batchSize
164+
If you send tens of thousands notifications at a time, you may get memory overflows due to how endpoints are called in Guzzle.
165+
In order to fix this, WebPush sends notifications in batches. The default size is 1000. Depending on your server configuration (memory), you may want
166+
to decrease this number. Do this while instanciating WebPush or calling `setDefaultOptions`. Or, if you want to customize this for a specific flush, give
167+
it as a parameter : `$webPush->flush($batchSize)`.
168+
162169
### Server errors
163170
You can see what the browser vendor's server sends back in case it encountered an error (push subscription expiration, wrong parameters...).
164171
`sendNotification()` (with flush as true) and `flush()` returns true if there were no errors. If there are errors it returns an array like the following.
@@ -285,8 +292,8 @@ require __DIR__ . '/path/to/vendor/autoload.php';
285292
```
286293

287294
### I must use PHP 5.4 or 5.5. What can I do?
288-
You won't be able to send any payload, so you'll be only able to use `sendNotification($endpoint)`.
289-
Install the libray with `composer` using `--ignore-platform-reqs`.
295+
You won't be able to send any payload, so you'll only be able to use `sendNotification($endpoint)`.
296+
Install the library with `composer` using `--ignore-platform-reqs`.
290297
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)).
291298

292299
### I lost my VAPID keys!

0 commit comments

Comments
 (0)