Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geolocation in Safari IPhone

I have web application which use geolocation. Geolocation in app is working on desktop (windows, chrome), notebook (linux, chrome), phone (iOS 15.1, chrome) but in phone (iOS 15.1, safari) I get error "User denied Geolocation". My web application using HTTPS.

I found in the internet a lot of similar issues but all issues were older then 5-10 years.

I don`t know what to do. Do I something bad or it is Safari bug?

This is example code on Codepen: https://codepen.io/jasonrammoray/pen/KONgZQ

var options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
};

function log(data) {
  const tag = document.createElement('p');
  tag.textContent = data;
  document.body.appendChild(tag);
}

function success(pos) {
  var crd = pos.coords;
  console.log('Successfully determined a user position:', crd);

  log('Your current position is:');
  log(`Latitude : ${crd.latitude}`);
  log(`Longitude: ${crd.longitude}`);
  log(`More or less ${crd.accuracy} meters.`);
}

function error(err) {
  console.warn(`ERROR(${err.code}): ${err.message}`);
}

navigator.geolocation.getCurrentPosition(success, error, options);
like image 881
Ondřej Krajčík Avatar asked Dec 29 '25 19:12

Ondřej Krajčík


1 Answers

The same happened to me! The problem is that you have the location disabled for Safari.

Go to iPhone settings > Privacy and security > location and make sure Safari is not set to "Never"

like image 120
Cibrán Docampo Avatar answered Jan 01 '26 13:01

Cibrán Docampo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!