Javscript geolocation issue on Safari browser on iOS device

I am using the code below to ask for location permission only for iOS devices when the component renders, below is the code snippet:

if (!!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform)) {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(
      success => {
        if (success) {
          const coords = {
            lat: success.coords.latitude,
            lng: success.coords.longitude,
          };
          this.fetchNearestLocation(coords);
          this.setState({ showCurrLocationMarker: true });
          this.setState({ isCurrentLocationBlocked: false });
        }
      },
      error => {
        if (error && error.code) {
          this.setState({ showCurrLocationMarker: false });
          this.setState({ isCurrentLocationBlocked: true });
        }
      },
    );
  }
} 

The issue here is that once the location access is blocked for Safari browser from the settings, and after sometime it is enabled again, I won't get the location permission popup at all.

I am confused whether the issue is related to the code or the browser (settings).

I was expecting to get a location permission pop-up on when the component renders on an iOS device on Safari browser.

Replies

Hello! I have the same geolocation issue in Next JS app, current position still works in other browsers but doesn't work in Safari. Perhaps you managed to solve this problem and you can share? Thanks