Fixes for push notifications
This defaults webPushNotifications
to false
so that localdev won't get push notifications by default (still need local.json config to have static/config.json override tho)
This also allows deactivation of serviceworker which should prevent push notifications entirely instead of just not showing them in config. Still, maybe should make it more decent and not kill off serviceworker but just cancel the push and notify BE about it, but right now it's not used for anything else, so it doesn't really matter.
closes #235 (closed)
Merge request reports
Activity
mentioned in issue #231 (closed)
Something like this (I didn't try myself) should remove a subscription from BE:
function removeSubscriptionFromBackEnd (token) { return window.fetch('/api/v1/push/subscription/', { method: 'delete', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` } }) .then((response) => { if (!response.ok) throw new Error('Bad status code from server.') return response.json() }) }
Edit: update snippet
Edited by minibikiniadded 8 commits
-
957b2a6f...e59b67e1 - 6 commits from branch
develop
- a4f09029 - small refactor, added push unsub notice for BE
- e3cac42c - Merge remote-tracking branch 'upstream/develop' into push_fix
-
957b2a6f...e59b67e1 - 6 commits from branch
@egor please check, I've updated it.
- refactored the whole thing to make it a bit easier to add further modifications, hopefully.
- Now telling BE that we no longer need push notifications
- Now correctly unsubscribing the PushManager before killing off SW
- Request to BE and FE PushManager/SW stuff are performed asynchronously.
TODO for future:
- Check if there's SW running and show it's in UI (i know some people might like better visibility that browser is doing something in background)
- Check if push subscription exist in BE? Option to kill all push subscriptions?
- Resolved by HJ
enabled an automatic merge when the pipeline for 500b4bd3 succeeds
mentioned in commit 0ad83784