The Extension Manager
The Web Push service requires an Extension Manager. This object manages extensions that will manipulate the request before sending it to the Push Service.
In the example below, we add all basic extensions.
use WebPush\ExtensionManager;
use WebPush\PreferAsyncExtension;
use WebPush\TopicExtension;
use WebPush\TTLExtension;
use WebPush\UrgencyExtension;
$extensionManager = ExtensionManager::create()
->add(TTLExtension::create())
->add(UrgencyExtension::create())
->add(TopicExtension::create())
->add(PreferAsyncExtension::create())
;Payload Extension
The payload extension allows Notifications to have a payload. This extension requires Content Encoding objects that will be responsible for the payload encryption.
The library provides the AESGCM and AES128GCM content encoding. These encodings are normally supported by all Push Services. The library is able to support any future encoding if deemed necessary.
Both content encodings require a PSR-20 Clock implementation. You can use symfony/clock for example.
VAPID Extension
The VAPID header authenticates your server and prevents malicious applications from sending notifications to your users. The header contains a signed JSON Web Token (JWS).
The library provides bridges for the following libraries web-token and lcobucci/jwt.
Please install web-token/jwt-library or lcobucci/jwt depending on the library you want to use.
The VAPID extension requires a PSR-20 Clock implementation. You can use symfony/clock for example.
The public key used with your server shall be the same as the one in your Javascript application.
If this public/private key changes, subscriptions will become invalid.
Last updated
Was this helpful?