Skip to content

Appendix

Stefan Kientzler edited this page Jul 26, 2021 · 1 revision

How long is a Subscription valid?

In principle, the information provided by the browser for a subscription also contains a time stamp when it expires. Almost no browser assigns a valid value to this data field (a correct value only was set by Edge). According to the specification for subscriptions that have an expiration date, the push service sends a 'pushsubscriptionchange' event to the corresponding service-worker before the expiration. In this case, the service-worker should re-subscribe the notifications.

If a user quit an existing subscription (generally by blocking the notifications for the page in the browser), this is forwarded by the browser to the corresponding push service. If the server then tries to send a notification to this endpoint it is not forwarded to the browser but the push service send a response code of 410 back to the server instead.

For those cases, the Notification Server has the option of removing subscriptions that are no longer valid from its database in order to avoid unnecessary data traffic.

However, if a browser is no longer in use, uninstalled or the system is no longer used for another reason (reinstallation, outdated, defective), the existing subscriptions that do not have an expiry date are retained in the database. The W3C and standard browser providers are considering getting this problem under control. Unfortunately, the notification server itself doesn't have a reliable way to detect inactive subscriptions.

Standardbrowser settings to display notifications

Most (desktop) standard browsers offer the option of setting whether a service provided by the operating system or an own implementation should be used to display the notifications.

Firefox

Type 'about:config' in the navigation field for the Internet URL and search for 'alerts'. The value 'alerts.useSystemBackend' controls the behaviour. If set to true, notifications are displayed by the operating system, otherwise the browsers internal implementation is used to display the notifications.

Google Chrome

Enter 'chrome://flags' in the navigation field for the Internet URL and then search for 'notifications'. The setting 'Enable native notifications' controls the output.

Microsoft Edge

Since the Edge Browser is very much integrated into the Windows operating system, it basically uses the Control Center to display the notifications.

Debugging and testing the service-workers

There are various options for debugging and testing the service-worker in the developer tools of the standard browsers.

Firefox

Type 'about: debugging#/runtime/this-firefox ' in the navigation field for the Internet URL. All registered service-workers are displayed below the list of the extensions. The service-worker can be started or logged off here. Once the service worker is started, an (empty…) test message can be pushed, or the console and debugger of the service-worker can be opened.

Google Chrome

Open the developer tools when the page from which the notifications are subscribed is open. The registered service-worker is displayed under the menu item 'Application'. Here you can start, stop, update or unregister the service-worker. A test message can also be sent and you can switch to the source code / debugger here.

Microsoft Edge

Similar to Chrome, MS Edge has a item in the main menu of the developer tools named 'Serviceworker'.