How to make web push notification
-
How to make web push notification in bagisto?
-
@gauravjain1
Bagisto does not provide browser/web push notifications out of the box. The built-in notification system is only for in-app admin notifications (such as the notification bell in the admin panel) and does not send push notifications to browsers.To add web push notifications, you have two options:
- Use the official Web Push Notification extension available on the Bagisto Marketplace.
- Implement your own solution using Firebase Cloud Messaging (FCM).
Implementing web push notifications with Firebase Cloud Messaging (FCM)
A typical implementation consists of the following steps:
-
Set up Firebase
- Create a Firebase project.
- Register a Web App.
- Generate a Web Push (VAPID) key.
- Download the Firebase service account credentials for server-side authentication.
-
Store browser tokens
- Register a Service Worker (
firebase-messaging-sw.js). - Request notification permission from the user.
- Retrieve the FCM registration token and store it in your Bagisto application.
- Register a Service Worker (
-
Send notifications
- Use an FCM package such as
kreait/laravel-firebaseorlaravel-notification-channels/fcmto send notifications through the FCM HTTP v1 API.
- Use an FCM package such as
-
Trigger notifications
- Listen to Bagisto events (for example, order placement or order status updates) and send push notifications to the stored FCM tokens.
Important notes
- Web push notifications require HTTPS (except on localhost during development).
- The Service Worker must be served from the application's root so it can control the entire site.
- Use the FCM HTTP v1 API, as the legacy FCM API is deprecated.
- Add your frontend JavaScript through a theme override or a
view_render_eventlistener instead of modifying Bagisto core files.
This approach allows you to send push notifications for events such as new orders, order status updates, promotions, or any other custom events in your Bagisto application.