This page covers advanced configuration options for Filament Webpush.
The default service worker is designed to handle basic push notification functionality, but you may need to customize it for your specific requirements.
After running the webpush:prepare command, the service worker file is located at:
public/sw.js
The WebPush JavaScript file that handles subscription and notification display is located at:
resources/js/webpush.js
You can customize this file and include it in your build process.
The Filament Webpush plugin has several configuration options:
FilamentWebpushPlugin::make()
->registerSubscriptionStatsWidget(true) // Show subscription stats widget
You can listen for subscription events in your application:
use NotificationChannels\WebPush\Events\NotificationSent;
use NotificationChannels\WebPush\Events\NotificationFailed;
use FilamentWebpush\Events\PushSubscriptionCreated;
use FilamentWebpush\Events\PushSubscriptionDeleted;
protected $listen = [
NotificationSent::class => [
YourNotificationSentListener::class,
],
NotificationFailed::class => [
YourNotificationFailedListener::class,
],
PushSubscriptionCreated::class => [
YourSubscriptionCreatedListener::class,
],
PushSubscriptionDeleted::class => [
YourSubscriptionDeletedListener::class,
],
];
Since Web Push notifications are queued, you may want to specify the queue they should use:
class NewPostPublished extends Notification implements ShouldQueue
{
use Queueable;
public $queue = 'notifications';
// ...
}
How can I help you explore Laravel packages today?