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

123
Views
How to handle push notification on inactive site?

I have a PWA website that can send and receive push notifications when somebody makes a call on the site.

I am using Firebase Messaging for push notifications, here is some code:

notification:
    {
        title:"Video call!",
        body:"Video call from:"+m,
        click_action: "https://......netlify.app/?x="+m
    },
    data:
    {
        title:"Video call!",
        email:m,
        contact_link:"https://......netlify.app/?x="+m

I append some important parameters in the URL. The result: When the site is in focus, I receive the notification in the background the onMessage function of Firebase which I can handle. It works. When the site is closed, the click_action opens the site with the parameters, and it's also working. The only thing that does not work is when the site is inactive (another tab is in focus in the browser). The notification comes in, I click on the push-notification, the site becomes focused, but nothing changes, the site does not even reload. The URL parameters stay the same as before, they do not change to the one in the link.

So what can I do to make the inactive website change to the same site but with the parameters in the link?

My service worker does not do much, but here it is, in case it's needed for a solution:

firebase.initializeApp({
    ....
  });

  const messaging=firebase.messaging();

  messaging.setBackgroundMessageHandler(function (payload) {
    console.log(payload);
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solved it by using onBackgroundMessage() in the service worker, which is exactly for situations like this.

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!