Pushpad
Articles › Browser Settings, Web Push Notifications

What happens to the push subscription when you clear data from browser?

  • # deliverability
  • # push-api

A user visits a website and subscribes to the notifications. Then, after some time, he opens the browser settings and clicks "clear data" in order to remove the history and all the data stored by the browser on the device. What happens to the notifications in this case?

The above scenario is quite common and worth analyzing. In particular we have tested the steps on Chrome, which has the largest market share.

When you visit a website and you subscribe to the notifications, your browser contacts its push service and generates a new push subscription (endpoint and keys). The push subscription is passed to the website using a JavaScript promise, but it is also stored locally on the device. The browser needs the subscription in order to fetch the notifications from the push service.

When you click "clear data" in the browser settings, all data, including the push subscription is removed from storage. This is what happens:

  • The push subscription is removed from the browser push service (to be more precise, it becomes expired and it will return 410 Gone when you try to send a notification to it)
  • The push subscription is removed from the local device (when you call PushManager.getSubscription() you will get null)
  • The permission is still granted (unless you also reset the permissions). This means that the next call to PushManager.subscribe() will subscribe the user and generate a new push subscription without displaying the permission prompt.

Accordingly, if you use Pushpad for sending the notifications and a subscriber clicks "clear data", you can expect the following:

  • The push subscription is detected as expired by Pushpad and is removed automatically as soon as you try to send a notification to it
  • The pushpad('status') method of the JavaScript SDK returns false, since the user is no longer subscribed (in this way your code knows that you should try to subscribe the user again)
  • The permission is still granted, so when you try to subscribe the user again, using pushpad('subscribe') for example, he will not see the browser permission prompt.

Basically the results of clearing the browser data are quite intuitive and if your code is built on a solid SDK, which doesn't make wrong assumptions, everything will work properly. If you use the Pushpad Javascript SDK you can't make any errors, because it provides a good layer of abstraction, otherwise, if you are building from scratch, pay attention to the fact that you can have a "granted" permission and no subscription (null) at the same time.