Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Firebase messaging for web. Multiple tabs notifications

I'm using Firebase Messaging for browser notifications. Problem is when multiple tabs are open. Notification for every tab is shown. Adding tag to options didn't help

firebase.initializeApp(constants.CONFIG); 
const messaging = firebase.messaging();

messaging.setBackgroundMessageHandler(({ data }) => { 
  const options = { 
    body: data.body, 
    data: { link: data.link, }, 
    icon: data.icon, 
  };

  const backgroundNotification = self.registration.showNotification(data.title, options);

  return backgroundNotification; 
});

I need only one notification to be displayed even when many tabs with same app are open

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Comment this line of code

  const backgroundNotification = self.registration.showNotification(data.title, options);

and use instead

                new Notification(notification.title, {
                body : notification.body,
                tag : notification.title,
                icon : notification.icon
            });
  • Note that - Tag is unique, If you have 2 tabs and you are sending a push with name title: title1 and title1, it will show the push only ones.

Example 3.5: https://notifications.spec.whatwg.org/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!