OneSignal Help & Documentation

Welcome to the OneSignal New IA developer hub. You'll find comprehensive guides and documentation to help you start working with OneSignal New IA as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Discussions

Browser Behavior Questions

Understanding how browsers handle web push notifications

What happens when users clear their browser cache and cookies?

Browsers have implemented the Web Push Standard in a way that when users clear their browser cookies and cache, they get unsubscribed from notifications. This is because subscribed user data is stored in the browser's IndexedDB storage. Removing that data makes the browser "forget" that subscriber.

However, clearing this data does not remove the permissions that have already been granted by the user to receive notifications in that browser.

If you are using an HTTPS site and did not select "My site is not fully https" in your OneSignal dashboard settings, then you can automatically re-subscribe users that return to your site after they clear their browser cache and cookies by making sure Auto Resubscribe is turned on in the configuration. If you are using a Custom Code setup, also make sure that autoRegister is not in the init call.

However, users will not be auto-resubscribed if they change their Browser's Notification Permissions to "Ask" or "Block":

Users will also not be auto-resubscribed if they clear notifications from the Browser's Notification Settings:

  • Chrome: chrome://settings/content/notifications
  • Firefox: about:preferences#privacy > Permissions > Notifications
  • Safari: Preferences > Websites > Notifications > Remove

When users get resubscribed, they will get a new OneSignal Player ID record. You can find your Player ID in the Console using await OneSignal.getUserId();

See other ways users can Unsubscribe from Notifications.


How do I test that "auto-resubscribe" is working?

On your site, subscribe to receive notifications.

You can open up your browser's developer console and type:

await OneSignal.getUserId(); - This will log your OneSignal Player ID.

You can also send yourself a notification from the console using:

OneSignal.sendSelfNotification(); - This will send a notification to yourself.

If you are successfully subscribed and did not get the notification, see Notifications Not Shown.

If you are not successfully subscribed, see Troubleshooting Web Push.

In the browser settings, you can clear your browser history, or:

  1. Select the Lock button on your site next to the URL
  2. Select Cookies
  3. Select your site
  4. Click "Remove"
  5. Click "Done"

Refresh the page. You will not be prompted to resubscribe.

Open the browser console and input:

await OneSignal.getUserUserId(); - This will be create a new OneSignal Player ID for you.

OneSignal.sendSelfNotification(); - This will send a notification to yourself.

You have successfully resubscribed to your site after clearing your browser cache.


Can users receive notifications even when the browser is closed?

Browsers behave differently across platforms. Please refer to the table below for support for receiving notifications even when the browser is closed.

Browser Name

Android

Windows

macOS

Chrome / Chromium

Yes

Yes

No

Firefox

Yes

Yes

No

Safari

N/A

N/A

Yes

Opera

Yes

Yes

No

Edge

Yes

Yes

No

Chrome - Chrome runs as a background process by default even when all the windows are closed. As long as the background process is running, notifications will still be received. If the Chrome background process is not running, notifications will not be received.

Firefox - On Mac OS X, the process still exists even if windows are closed, and a notification can be received if all windows are closed (as long as there is still a dot in the dock showing Firefox is still running). On Windows, the process exits after all windows are closed so notifications cannot be received unless a Firefox window is still open.

Safari - Safari does not have to be running to receive notifications, as they are sent directly to the operating system. The user still has to sign up for Safari web notifications, but after that they will be received even when Safari is completely closed.

Users have up to 3 days to retrieve the last known missing notification before messages expire permanently.

For example, suppose a user was supposed to receive a Firefox web push notification, but Firefox was closed. If the user opens Firefox within 3 days, the user will receive only the last known web push notification that didn't expire. If the user opens Firefox after 3 days, the web push notification sent more than 3 days ago will not be received.

Updated 10 months ago



Browser Behavior Questions


Understanding how browsers handle web push notifications

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.