Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ $notifications = [
'endpoint' => 'https://example.com/other/endpoint/of/another/vendor/abcdef...',
'publicKey' => '(stringOf88Chars)',
'authToken' => '(stringOf24Chars)',
'contentEncoding' => 'aesgcm', // one of PushManager.supportedContentEncodings
'contentEncoding' => 'aesgcm', // encoding supported by both the browser and this library
]),
'payload' => '{"message":"test"}',
]
Expand Down Expand Up @@ -130,6 +130,21 @@ $report = $webPush->sendOneNotification(
);
```

#### Content encoding negotiation

Browsers can expose supported content encodings through `PushManager.supportedContentEncodings`. The library exposes its supported encodings through the public `ContentEncoding` enum, so applications can negotiate without duplicating a hard-coded list:

```php
use Minishlink\WebPush\ContentEncoding;

$librarySupportedContentEncodings = array_map(
static fn (ContentEncoding $encoding): string => $encoding->value,
ContentEncoding::cases(),
);
```

Use this list to validate or negotiate the browser-provided encodings before creating the `Subscription`, then pass the selected value as `contentEncoding`. If there is no overlap, treat the subscription as unsupported instead of guessing an encoding.

### Authentication (VAPID)

Browsers need to verify your identity. A standard called VAPID can authenticate you for all browsers based on [RFC8292](https://www.rfc-editor.org/rfc/rfc8292).
Expand Down