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

235
Views
How to handle Firebase push notification when site is already open?

I have a PWA that sends a notification to people when they are being called. It only works when the PWA isn't open, or the site isn't in focus. How can I still receive the notification in the app/site even if it's already in focus? I want the PWA to notice that it received a push-notification even if it's already open, perhaps handle things differently in that case.

I have this code for sending the notification:

function sendNotification(){
    const toSend ={
        notification:
        {
            title:"Video Call!",
            body:"Video call!",
            click_action: "https://....netlify.app/?x="+m,
            sound: "default",
            vibrate: [200, 100, 200, 100, 200, 100, 200]
        },
        to:othermailandtoken[1] 
        };
        
        const jsonString = JSON.stringify(toSend);
        
        
      var xhr = new XMLHttpRequest();
      xhr.open('POST', 'https://fcm.googleapis.com/fcm/send', true);
        xhr.onload = function(){
        console.log("google response: ",this.responseText);
        }
        
      xhr.setRequestHeader("Content-type", "application/json");
      xhr.setRequestHeader("Authorization","key=....");
    xhr.send(jsonString);
}
about 4 years ago · Juan Pablo Isaza
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!