Push notifications require new user permission every time browser cookies are cleared

bzcomputers

Well-known member
Affected version
2.2.9
I'm not sure if this is a bug or suggestion/request. It appears XenForo does not currently check for already existing browser push notification permissions, or if it does it is currently not working as it should.

After clearing cookies on a browser when I log back into any XenForo based site account that I have enabled push notifications for I am again asked to enable push notifications. This only seems to happen on XenForo sites for me. For other sites on which I have push notifications enabled this does not happen because the site checks for existing push notification permissions and automatically resubscribes.

I see the push notification permissions for XenForo sites still exist within the browser settings after cookies are cleared, so checking for them and automatically resubscribing should be possible.

Requiring a user to resubscribe to push notifications after each cookie clearing will definitely cut down on push notification users.
 

digitalpoint

Well-known member
I suspect it has to do with push notifications not being a 1:1 thing. Specifically, a single user account can receive push notifications on multiple devices (well more accurately, browsers) and users can pick which devices they want to receive them at. If you clear the cookies, it thinks it's a new browser so it's asking if you want to receive push notifications there. You can't just assume that a new browser is the same one that already subscribed to push notifications, because it might not be.
 

bzcomputers

Well-known member
The push notification permissions for a site are stored locally in the browser. So it would only be checking for existing permissions on that specific browser and if you have already approved push notifications for that browser it just resubscribes.
 

digitalpoint

Well-known member
I haven't tested it, but ya... I suppose if Notification.permission == 'granted', but there's no xf_push_subscription_updated cookie, you could xf_push_subscription_updated to "1". That might be a simple fix (I haven't tested it).
 
Top