If possible find a more standard (without workarounds) way to solve a repetitive subscriptions and unsubscriptions ...
Use case:
A user gets the popup and clicks the "Allow" button, so the service worker will be registered.
Afterwards the user blocks the Node-RED dashboard from sending notifications (via the browser settings) or the service worker is disabled.
And some time after that, the user allows the dashboard again sending notifications.
We cannot detect the unsubscription (2) easily, since not all browsers (e.g. Chrome) don't call the pushsubscriptionchange event.
But we really need to handle the unsubscriptions, because otherwise the subscription list (in Node-RED) will keep growing and the number of inactive subscriptions will keep increasing. Which means will keep sending notifications to inactive subscribers, which will fail anyway ...
It seems that we can only workaround it like this: when the Node-RED flow sends a notification, we will analyse the result. If it failed (http status 410) we will automatically remove the subscription from our list.
That works fine. But when the dashboard is granted again to send notifications (3), our service worker won't be informed (by the browser) about that! To workaround that the service worker will registers itself (every time the 'granted' widget is started) in Node-RED. Unfortunately this is pure overhead, but I don't see another way to let Node-RED flow know that the subscription is active.
If possible find a more standard (without workarounds) way to solve a repetitive subscriptions and unsubscriptions ...
Use case:
We cannot detect the unsubscription (2) easily, since not all browsers (e.g. Chrome) don't call the
pushsubscriptionchange
event.But we really need to handle the unsubscriptions, because otherwise the subscription list (in Node-RED) will keep growing and the number of inactive subscriptions will keep increasing. Which means will keep sending notifications to inactive subscribers, which will fail anyway ...
It seems that we can only workaround it like this: when the Node-RED flow sends a notification, we will analyse the result. If it failed (http status 410) we will automatically remove the subscription from our list.
That works fine. But when the dashboard is granted again to send notifications (3), our service worker won't be informed (by the browser) about that! To workaround that the service worker will registers itself (every time the 'granted' widget is started) in Node-RED. Unfortunately this is pure overhead, but I don't see another way to let Node-RED flow know that the subscription is active.