Opscale\NotificationCenter\Notifications\WebPushNotificationChannel identifier:
webpushUnderlying driver:
NotificationChannels\WebPush\WebPushChannel
WebPushNotification sends a browser push notification to all active push subscriptions associated with the delivery’s profile, using the laravel-notification-channels/webpush package and the Web Push Protocol.
Requirements
Method signatures
via()
Returns [WebPushChannel::class], routing the notification through the WebPush channel.
toWebPush(object $notifiable, mixed $notification): WebPushMessage
Builds and returns a NotificationChannels\WebPush\WebPushMessage. The payload is:
| Field | Source |
|---|---|
| Title | $delivery->notification->subject |
| Body | $delivery->notification->summary |
| Icon | asset('favicon.png') |
| Action button | ”More Details” linking to the tracked open route |
getSubscription(): mixed
Overrides the base class to return all push subscriptions (pushSubscriptions) on the delivery’s profile, rather than a single contact value. The WebPush channel iterates these subscriptions and sends to each active browser endpoint.
What data it sends
The push message delivered to the browser contains:- A title string from the notification’s
subject - A body string from the notification’s
summary - An icon loaded from
favicon.pngat the application’s public root - A “More Details” action button linking to the tracked open URL
Usage example
Thewebpush channel is included in the system, alert, and reminder strategies by default:
SubscribeTemplate mailable which includes the registration URL, service worker URL, and VAPID public key:
The notifiable model must use the
HasPushSubscriptions trait from the laravel-notification-channels/webpush package so that $profile->pushSubscriptions resolves correctly.