Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

313
Vistas
How to ask permission for geolocation every time?

I would like to be asked every time for the permission to access to geolocation. How to do that? I thought to revoke the permission everytime and then ask it for again, but that doesn't work. According to documentation it has been deprecated.

navigator.permissions.query({name:'geolocation'}).then(function(result) {
  if (result.state === 'granted') {
   //to do things here 
  
  } else if (result.state === 'prompt') {
   //ask for permission
  
  } else if(result.state === 'denied'){
   //keep asking for permission
  
  }
  report(result.state);
});

/////

  if ('geolocation' in navigator) {
      console.log('there is geolocation')
      navigator.geolocation.getCurrentPosition((success) => {
        console.log('success geo', success.coords)
        
      }, (error) => {
        console.log(error, 'error')
      }, { maximumAge: 0});

    } else{
      alert('Please grant access to location')
    }
  }

From what I have been reading, it seems that once the user has given access to location, the browser remembers. That's why I added also maximumAge; I thought that adding that, I could have a mechanism to allow to ask for the geolocation permission every time the user loads a page.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda