Notification Setup
Web push notifications allow you to engage with your users even when they're not actively using your website. Follow these steps to set up notifications for your eBroker web application.
Getting the VAPID API Key
To enable web push notifications, you need to set up VAPID (Voluntary Application Server Identification) keys:
- Go to your Firebase project in the Firebase Console
- Navigate to Project Settings > Cloud Messaging
- Scroll down to the Web configuration section
- Find the Web Push certificates section
- Generate a new key pair if you don't already have one
- Copy the key pair information
Configuring VAPID Key in Your Project
- Open the
.env
file in your project's root directory - Find the VAPID API key variable
- Paste your VAPID key into this variable
Testing Notifications
After setting up the VAPID key:
- Restart your development server
- Try to subscribe to notifications in your web application
- Send a test notification to verify the setup is working correctly
Troubleshooting
If notifications aren't working:
- Make sure your VAPID key is correctly configured in your
.env
file - Check that your Firebase project is properly set up
- Verify that your browser supports web push notifications
- Check for permission issues (users must grant notification permissions)
- Look for errors in the browser console
Best Practices
For effective push notifications:
- Only ask for notification permission after establishing user value
- Keep notifications relevant and timely
- Allow users to easily manage their notification preferences
- Don't overwhelm users with too many notifications