Skip to content
Snippets Groups Projects

Fixes for push notifications

Merged HJ requested to merge push_fix into develop
All threads resolved!

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)

Edited by HJ

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • HJ changed the description

    changed the description

  • HJ mentioned in issue #231 (closed)

    mentioned in issue #231 (closed)

    1. unregisterPushNotifications() should remove a subscription on BE too.
    2. Not sure if unregistering ServiceWorker is a good idea. ServiceWorker could be useful for other things (like caching) later. But right now yeah we only use it for web push.
  • 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 minibikini
  • HJ marked as a Work In Progress

    marked as a Work In Progress

  • HJ added 8 commits

    added 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

    Compare with previous version

  • HJ unmarked as a Work In Progress

    unmarked as a Work In Progress

  • Author Maintainer

    @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?
  • minibikini
  • HJ added 1 commit
  • HJ resolved all discussions

    resolved all discussions

  • HJ enabled an automatic merge when the pipeline for 500b4bd3 succeeds

    enabled an automatic merge when the pipeline for 500b4bd3 succeeds

  • HJ merged

    merged

  • HJ mentioned in commit 0ad83784

    mentioned in commit 0ad83784

  • Please register or sign in to reply
    Loading