Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
Open page on same window when user click on notification

I want to open the notification link on the same page and now I am using return client.openWindow(navUrl); but there is one issue it’s open on a different tab. Can anyone guide me or help me to understand the difference between the Window and windowClients because I am not aware of the javascript and I need for complete for push notification.

Also, Window is not working in my firebase-messaging-sw.js file

here I attached my code

event.waitUntil(
  clients.matchAll({
    type: 'window',
    includeUncontrolled: true
  }).then(windowClients => {
    // Check if there is already a window/tab open with the target URL
    for (let i = 0; i < windowClients.length; i++) {
      var client = windowClients[i];
      // If so, just focus it.
      console.log('here');
      if (client.url.startsWith(OriginalUrl) && 'focus' in client) {
        console.log('window found');
        // client.claim().then(()=>{
        //  console.log('claimed');
        //  client.focus().then(function(windowClient) {
        //      console.log('focusing');
        //      windowClient.focus();
        //      console.log('focused');
        //      // windowClient.navigate(navUrl);
        //    });
        // });
        // break;
        return clients.openWindow(navUrl);
      }
    }
    // If not, then open the target URL in a new window/tab.
    // if (clients.openWindow) {  
    //  console.log('window not found opening new');
    //  event.waitUntil(clients.claim());// this 
    //     return clients.openWindow(navUrl);
    // }
  })
);
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda