Skip to content

Commit 49b204d

Browse files
committed
add paragraph on server errors in README
1 parent 3be4d21 commit 49b204d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ Urgency can be either "very-low", "low", "normal", or "high". If the browser ven
124124
#### topic
125125
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)).
126126

127+
#### Server errors
128+
You can see what the browser vendor's server sends back in case it encountered an error (push subscription expiration, wrong parameters...).
129+
`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.
130+
The `expired` key can be useful to clean your database of expired endpoints.
131+
132+
```php
133+
$res = array(
134+
array( // first notification
135+
'success' => false,
136+
'statusCode' => $responseStatusCode,
137+
'headers' => $responseHeaders,
138+
'content' => $responseContent, // you may have more infos here
139+
'expired' => $isTheEndpointWrongOrExpired,
140+
),
141+
array( // second notification
142+
...
143+
), ...
144+
);
145+
```
146+
127147
### Payload length and security
128148
Payload will be encrypted by the library. The maximum payload length is 4078 bytes (or ASCII characters).
129149

0 commit comments

Comments
 (0)