WebPushSender - viames/pair GitHub Wiki
Pair framework: WebPushSender
Pair\Push\WebPushSender delivers a single push notification to one subscription using VAPID and minishlink/web-push.
Requirements
Composer package:
composer require minishlink/web-push
If library is missing, constructor throws RuntimeException.
Constructor
$sender = new \Pair\Push\WebPushSender();
Optionally pass custom VapidConfig.
Main method
send(Notification $notification, PushSubscription $subscription): DeliveryResult
Behavior:
- builds WebPush auth config from VAPID keys
- creates Minishlink subscription object
- serializes notification payload as JSON
- sends notification and parses report
- marks invalid subscriptions (
404,410) withshouldDeleteSubscription=true
Apple encoding note
For host web.push.apple.com, Pair uses aes128gcm; otherwise default aesgcm.
Minimal example
$result = $sender->send($notification, $subscription);
if (!$result->success) {
// inspect $result->error and $result->statusCode
}
See also: VapidConfig, PushDispatcher, PairPush.js.