handle desktop notifications clicks
This commit is contained in:
parent
6ed2cb8f43
commit
a17defc5ab
4 changed files with 31 additions and 8 deletions
|
|
@ -82,12 +82,18 @@ function sendSubscriptionToBackEnd (subscription, token, notificationVisibility)
|
|||
return responseData
|
||||
})
|
||||
}
|
||||
export async function initServiceWorker () {
|
||||
export async function initServiceWorker (store) {
|
||||
if (!isSWSupported()) return
|
||||
await getOrCreateServiceWorker()
|
||||
navigator.serviceWorker.addEventListener('message', (event) => {
|
||||
const { dispatch } = store
|
||||
console.log('SW MESSAGE', event)
|
||||
// TODO actually act upon click (open drawer on mobile, open chat/thread etc)
|
||||
const { type, ...rest } = event
|
||||
|
||||
switch (type) {
|
||||
case 'notificationClicked':
|
||||
dispatch('notificationClicked', { id: rest.id })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue