Web Push Advanced Options
Advanced OneSignal web push configuration including localhost testing, service worker setup, notification click behavior, persistence settings, and webhook implementation for custom integrations.
The Advanced section covers specialized configurations and notification behaviors for customers with specific requirements or custom implementations.
Web Push Webhooks
OneSignal provides dedicated Web Push Webhooks for handling notification events. See Web Push Webhooks for complete implementation details.
Important: Web Push Webhooks are a separate implementation from Event Webhooks and cannot be used interchangeably.
Service Worker Configuration
OneSignal automatically checks the root scope for service workers by default. However, we strongly recommend customizing your integration to use a non-root scope for better security and to avoid conflicts with existing service workers.
Follow our OneSignal Service Worker Setup guide to implement a custom scope configuration.
Why use a non-root scope?
- Prevents conflicts with existing service workers
- Improves security by limiting OneSignal’s scope
- Provides better control over your site’s service worker architecture
Local Development and Testing
For development and testing purposes, see our comprehensive Local Testing guide which covers:
- Setting up localhost environments
- Testing notifications without SSL certificates
- Debugging common development issues
Notification Click Behavior
OneSignal supports multiple browser behaviors when users click notifications. For advanced URL handling and options like disabling click actions entirely, see Deep-links and URLs.
Default Behavior
When users click a notification and do not have your site open, the browser opens a new tab and navigates to the notification’s URL.
When Site is Already Open
When users have your site open in one or more browser tabs, you can configure how the browser responds:
Exact Navigate (Default)
- Matches the notification’s exact URL (e.g.
example.com/product
) to an open tab - Navigates to the notification’s URL in that matching tab
- Best for specific page targeting
Origin Navigate
- Matches the notification’s origin (e.g.
example.com
) to any open tab from your site - Navigates to the notification’s URL in the matched tab
- Useful for general site navigation
Exact Focus
- Matches the notification’s exact URL to an open tab
- Focuses on that tab without refreshing the page
- Ideal when you don’t want to disrupt user’s current page state
Origin Focus
- Matches the notification’s origin to any open tab from your site
- Focuses on that tab without refreshing the page
- Best for bringing attention to your site without navigation
Notification Persistence
By default, notifications display for approximately 5 seconds before moving to the Notification History, where they remain for 1 week before automatic removal by the operating system.
Enabling Persistent Notifications
You can make notifications persist on screen until user interaction for Chrome and Edge browser subscribers.
Not all browsers and operating systems support persistent notifications. When enabled, it only affects eligible users and may impact notification appearance by reducing character count and affecting image/button display.
Important Considerations:
- Current subscribers must revisit your site after enabling this setting to see changes
- Persistent notifications may annoy users if overused
- Recommended only for high-importance notifications (e.g., task management apps)
- Users can hover over notifications to keep them visible for reading
Implementation Methods
Dashboard Configuration
Use the “Persistence” toggle in your OneSignal dashboard to enable/disable this feature.
Notification Persistence Toggle
Custom Code Implementation
Add the persistNotification
property to your Web Push SDK initialization:
Include this in your OneSignal init code to enable persistence for supported browsers and operating systems.
Browser Compatibility
Supported Browsers:
- Chrome (full support)
- Edge (full support)
Unsupported Browsers:
- Firefox (setting has no effect)
- Safari (setting has no effect)
Best Practices
- Use sparingly: Only enable for truly important notifications to avoid user frustration
- Test thoroughly: Verify behavior across different browsers and devices
- Monitor user feedback: Watch for increased opt-out rates that may indicate notification fatigue
- Consider context: Persistent notifications work best for time-sensitive or actionable content
Next Steps:
- Review your notification strategy to determine if persistence is appropriate
- Test the feature with a small user segment before full deployment
- Monitor engagement metrics after implementation
- Consider implementing different persistence settings for different notification types