Skip to content

PushDispatcher

Viames Marino edited this page Feb 22, 2026 · 1 revision

Pair framework: PushDispatcher

Pair\Push\PushDispatcher sends a notification to all active subscriptions of a user.

It coordinates:

  • SubscriptionRepository (load subscriptions)
  • WebPushSender (deliver notification)
  • automatic cleanup of invalid endpoints

Usage

use Pair\Push\PushDispatcher;
use Pair\Push\Notification;

$dispatcher = new PushDispatcher();

$notification = new Notification(
    'Order updated',
    'Your order #123 has been shipped',
    '/orders/123',
    '/img/icon.png',
    'order-123'
);

$results = $dispatcher->sendToUser(42, $notification);

sendToUser() returns a list of DeliveryResult objects, one per subscription.

Behavior details

  • fetches all non-revoked subscriptions for user
  • sends one push per subscription
  • if provider returns 404 or 410, subscription is deleted

See also: SubscriptionRepository, WebPushSender, VapidConfig, PairPush.js.

Clone this wiki locally