User unsubscribed from push notifications when in admin

digitalpoint

Well-known member
Affected version
2.2.13
If you are subscribed to push notifications, that subscription is removed from the xf_user_push_subscription when you enter the admin area. There is a mechanism that automatically deletes the user's push subscription record if the user doesn't have a user_id (XF.config.userId) so a user of a browser doesn't get some other user's push notifications if they log out of the browser. Since admin and public are different apps, logging into the admin area gives the user a userId of 0 on the admin login form.

The end result is that you stop receiving push notifications while you are in the admin area until you visit a public page again. Becomes really weird when you are working in the admin for long periods of time without going to a public page or if you went to the admin area and then went to bed or something.

Look at your subscriptions in the xf_user_push_subscription table, then log into admin area and look at that table again... poof! your push subscription record is deleted (and you aren't getting push notifications) until you return to a public page.
 
If you are subscribed to push notifications, that subscription is removed from the xf_user_push_subscription when you enter the admin area. There is a mechanism that automatically deletes the user's push subscription record if the user doesn't have a user_id (XF.config.userId) so a user of a browser doesn't get some other user's push notifications if they log out of the browser. Since admin and public are different apps, logging into the admin area gives the user a userId of 0 on the admin login form.

The end result is that you stop receiving push notifications while you are in the admin area until you visit a public page again. Becomes really weird when you are working in the admin for long periods of time without going to a public page or if you went to the admin area and then went to bed or something.

Look at your subscriptions in the xf_user_push_subscription table, then log into admin area and look at that table again... poof! your push subscription record is deleted (and you aren't getting push notifications) until you return to a public page.
Is this issue separate to the issue with iOS losing our subscriptions in the PWA?
 
Not sure… I’ve just been adding fixes for all the possibilities I’ve found, and so far I haven’t seen my subscriptions disappear, but that’s not definitive or a big test.
 
I've been rolling them into the next version of this addon, so ya.

 
I've been rolling them into the next version of this addon, so ya.

Oh that is good news. Thanks! I will keep an eye out.
 
I am also experiencing weird push notifications that only push when i visit the site. The moment i visit the forum notifications start coming through.
 
I am also experiencing weird push notifications that only push when i visit the site. The moment i visit the forum notifications start coming through.
Could that be a background sync issue on your device that's preventing notifications from being pushed to background apps?
 
I am also experiencing weird push notifications that only push when i visit the site. The moment i visit the forum notifications start coming through.
When the PWA visits the site for the first time, it attempts to update push subscriptions. So it’s going to be because of that. Why the subscription was lost in the first place in your case, who knows…
 
Top Bottom