Geolocation in Safari IPhone

Viewed 80

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);
0 Answers
Related