PWA notification grouping

Viewed 422

I have created a PWA and implemented push notifications. From what I understand notifications can be replaced using tag and behaviour controlled using renotify. Google documentation here.

This may be a good way to keep down the amount of displayed notifications, but is there a way to group notifications in a PWA?

In native apps I have noticed that notifications get "grouped" or "stacked" into one notification if there are more than a certain amount of notifications. Can this be achieved in a PWA?

Code for showing a push notification:

self.addEventListener('push', function (event){
  console.log('Push Notification received', event)
  const defaultData = {title: 'New!', content: 'Something new happened!', openUrl: '/'}
  const data = (event.data) ? JSON.parse(event.data.text()) : defaultData

  var options = {
    body: data.content,
    icon: '/img/ico/manifest-512.png', 
    badge: '/img/ico/badge96.png', 
    // tag: 'myTag', 
    // renotify: true,
    data: {
      url: data.openUrl
    }
  }

  event.waitUntil(
    self.registration.showNotification(data.title, options)
  )
})

Kind regards /K

0 Answers
Related