That works. Any fix identified for future release?I’ve never had to reinstall. That seems to be a common thing people say needs to be done to get it working.
You should just be able to enable push notifications again in your preferences.
That works. Any fix identified for future release?I’ve never had to reinstall. That seems to be a common thing people say needs to be done to get it working.
You should just be able to enable push notifications again in your preferences.
Ah ha! This explains some of the questions I'm getting re notifications.You should just be able to enable push notifications again in your preferences.
XF.config.userId set, so the browser (and PWA) is told to unsubscribe from push notifications.if (XF.config.userId && isExpectedServerKey(subscription))
{
XF.Push.updateUserSubscription(subscription, 'update');
}
else
{
subscription.unsubscribe();
XF.Push.updateUserSubscription(subscription, 'unsubscribe');
}
Notification.permission = "granted" but XF.Push.isSubscribed = false. And you can't programmatically resubscribe because the browser only allows a push subscription to "start" (since it was killed on the two-step page) with a user gesture.XF.Push.handleSubscribeAction(true);
>> Notification prompting can only be done from a user gesture.
Notification.permission = "granted" already). Chrome (probably other browsers too, but I'm only testing with Chrome and Safari right now) does not require a user gesture to re-enable push notifications.XF.PWA.getRegistration()
.then(function(registration)
{
return registration.pushManager.getSubscription();
})
.then(function(subscription)
{
subscription.unsubscribe();
});
XF.Push.handleSubscribeAction(true);
misc/update-push-subscription on the Network tab.Notification prompting can only be done from a user gesture.
Permission was not granted
XF.Push.handleSubscribeAction() forcing Notification.requestPermission(), instead check if the browser has a subscription, and simply use that if there's already one in place for the browser. That should work for all browsers.navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {
serviceWorkerRegistration.pushManager.getSubscription().then(function (subscription) {
if (subscription) {
// Browser has a subscription already, use it.
console.log(JSON.stringify(subscription));
XF.Push.updateUserSubscription(subscription, 'insert');
XF.Push.isSubscribed = true;
} else {
// go the Notification.requestPermission() route...
}
});
});
xf_user_push_subscription.push_state column where the unsubscribe action toggles that between active/disabled to prevent push notifications from being sent to a browser where the user "logged out". Then it can be reactivated programmatically without relying on the browser (and sometimes needing a user gesture).We use essential cookies to make this site work, and optional cookies to enhance your experience.