Requirements
- HTTPS website: Web push does not work on HTTP or in incognito/private modes.
- Server access: You’ll need to upload a service worker file to your site.
- Single origin: Web push follows the Same-origin policy. If you have multiple origins (domains/subdomains), you will need multiple OneSignal apps (one per origin). To comply with this browser limitation, you can either:
- Redirect traffic to a single origin for subscriptions.
- Create multiple OneSignal apps—one per origin.
Configure your OneSignal app and platform
In the OneSignal dashboard:- Go to Settings > Push & In-App > Web.
- Select the Custom Code integration type.
Site setup
Add the site details:- Site Name: The name of your site and default notification title.
- Site URL: The exact origin of your site, e.g.,
https://yourdomain.com. Avoid usingwww.if your site isn’t configured that way. See Requirements if you have multiple origins. - Auto Resubscribe: Enable this to automatically resubscribe users who clear their browser data when they return to your site (no new permission prompt required).
- Default Icon URL: Upload a square
256x256pxPNG or JPG image that appears in notifications and prompts. If not set, a bell icon is used as the default.

Web settings in the OneSignal dashboard
Local testing
To test on localhost, use a separate OneSignal app from your production app and addallowLocalhostAsSecureOrigin: true to your init options.
If you’re testing localhost on HTTPS with a self-signed certificate, you may need to tell Chrome to ignore invalid certificates with --allow-insecure-localhost. Firefox and Safari provide built-in mechanisms to add exceptions for security certificates.
Safari web push certificate (optional)
OneSignal provides Safari certificates automatically at no cost. Only enable this if you have existing Safari Web Push certificates you need to use.
Safari certificate upload option for existing certificates
Safari Web .p12 Push Certificate and enter the password.
Click Save to continue.
Upload service worker files
On the next page of web push configuration, you will be provided theOneSignalSDKWorker.js service worker file.
The web SDK looks for this file in the root of your site by default, e.g., https://yourdomain.com/OneSignalSDKWorker.js. You can change the file location, name, and scope in code.
OneSignal service worker
Add code to site
Add this code to your website’s<head> section. Replace:
YOUR_ONESIGNAL_APP_IDwith your actual App ID from the OneSignal dashboardYOUR_SAFARI_WEB_IDwith your actual Safari Web ID from the OneSignal dashboard
iOS web push support
Apple started supporting web push notifications on iPhones and iPads running iOS 16.4+. Unlike Android devices where web push just “works” as long as visited on a supported browser, Apple added a few more requirements such as amanifest.json file and a user action to add your site to their home screen.
iOS web push setup
manifest.json file and guide users to add your site to their home screen.Testing the OneSignal SDK integration
This guide helps you verify that your OneSignal SDK integration is working correctly by testing push notifications and subscription registration.Check web push subscriptions
Launch your site on a test device.
- Use Chrome, Firefox, Edge, or Safari while testing.
- Do not use Incognito or private browsing mode. Users cannot subscribe to push notifications in these modes.
- The prompts should appear based on your permission prompts configuration.
- Click Allow on the native prompt to subscribe to push notifications.

Web push native permission prompt
Check your OneSignal dashboard
- Go to Audience > Subscriptions.
- You should see a new entry with the status Subscribed.

Dashboard showing subscription with 'Subscribed' status
Set up test users
test users are helpful for testing a push notification before sending a message.Add to Test Users.

Adding a device to Test Users
Name your subscription.
Create a test users segment.
Name the segment.
Test Users (the name is important because it will be used later).Add the Test Users filter and click Create Segment.

Creating a 'Test Users' segment with the Test Users filter
Send test push via API
Get your App API Key and App ID.
Update the provided code.
YOUR_APP_API_KEY and YOUR_APP_ID in the code below with your actual keys. This code uses the Test Users segment created earlier.Run the code.
Check images and confirmed receipt.

Expanded push notification with image on Chrome macOS
Check for confirmed receipt.
Push notification message reports
support@onesignal.com with the following:
- The API request and response (copy-paste into a
.txtfile) - Your Subscription ID
- Your website URL with the OneSignal code
User identification
The previous section covered creating web push Subscriptions. This section expands to identifying Users across all their subscriptions (including push, email, and SMS) using the OneSignal SDK. It covers External IDs, tags, multi-channel subscriptions, privacy, and event tracking to help you unify and engage users across platforms.Assign External ID
Use an External ID to identify users consistently across devices, email addresses, and phone numbers using your backend’s user identifier. This ensures your messaging stays unified across channels and 3rd party systems (especially important for Integrations). Set the External ID with the SDK’slogin method each time a user is identified by your app.
Add Tags
Tags are key-value pairs of string data you can use to store user properties (likeusername, role, or preferences) and events (like purchase_date, game_level, or user interactions). Tags power advanced Message Personalization and Segmentation allowing for more advanced use cases.
Set tags with the SDK’s addTag and addTags methods as events occur in your app.
In this example, the user reached level 6 identifiable by the tag called current_level set to a value of 6.

A user profile in OneSignal with a tag called "current_level" set to "6"

Segment editor showing a segment targeting users with a current_level value of greater than 4 and less than 10

Push notification targeting the Level 5-10 segment with a personalized message
Add email and/or SMS subscriptions
The OneSignal SDK creates web push subscriptions automatically when users opt in. You can also reach users through email and SMS channels by creating the corresponding subscriptions.- Use the
addEmailmethod to create email subscriptions. - Use the
addSmsmethod to create SMS subscriptions.

A user profile with push, email, and SMS subscriptions unified by External ID
- Obtain explicit consent before adding email or SMS subscriptions.
- Explain the benefits of each communication channel to users.
- Provide channel preferences so users can select which channels they prefer.
Privacy & user consent
To control when OneSignal collects user data, use the SDK’s consent gating methods:setConsentRequired(true): Prevents data collection until consent is given.setConsentGiven(true): Enables data collection once consent is granted.
Data collected by the SDK
Handling personal data
Listen to push, user, and in-app events
Use SDK listeners to react to user actions and state changes. The SDK provides several event listeners you can hook into. See the SDK reference guide for more details.Push notification events
- Click event listener: Detect when a notification is tapped.
- Foreground lifecycle listener: Control how notifications behave in foreground.
User state changes
- User state change event listener: Detect when the External ID is set.
- Permission observer: Track the user’s specific interaction with the native push permission prompt.
- Push subscription change observer: Track when the push subscription status changes.