Browser Behavior Questions
Understand 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 cache and cookies, 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 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, then you can automatically re-subscribe users that return to your website after they clear their browser cache and cookies. This is already configured in the iZooto SDK and happens automatically as soon as the user revisits your website without having to allow for push notifications again.
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 browser key. You can access your browser key from the Browser Developer Console tool.
How do I test that "auto-resubscribe" is working?
On your website, ensure that you are subscribed to receive notifications.
You can open up your browser's developer console and type: _izooto.getBrowserKeyFromToken(_izooto.getStorage('iztoken'));
- this will display the browser key. Make a note of it.
Try sending yourself a test notification once you see the browser key generated in the console.
If you are successfully subscribed and did not get the notification, please refer to Notifications Not Shown guide.
If you are not successfully subscribed, please see our Web Push Troubleshooting.
In the browser settings, you can clear your browser data:
- Select the "lock" button next to the website URL.
- Select Cookies.
- Select your website.
- Click "Remove".
- Click "Done".
Refresh the page. You will not be prompted to resubscribe.
Open the browser developer console and type: _izooto.getBrowserKeyFromToken(_izooto.getStorage('iztoken'));
- you will see a different browser key as compared to before clearing the browser data.
Try sending yourself a test notification again. If you receive the notification, you have successfully resubscribed to your website 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 | No | No |
Firefox | Yes | No | No |
Safari | N/A | N/A | Yes |
Opera | Yes | No | No |
Edge | Yes | No | 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 service 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 a 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 push notifications, but after that they will be received even when Safari is completely closed.
Users have up to 1 day 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 1 day, the user will receive only the last known web push notification that did not expire. If the user opens Firefox after 1 day, the web push notification sent more than 1 day ago will not be received.
Updated almost 3 years ago