Safari geolocation failure


I have a pwa that is not accessing the phones location (location is on and Safari has permission). Chrome works fine on Android OS but on iPhone the fail function is called after the navigator.geoloc… code.

Is there something I need to do to get geolocation working in Safari/iOS?

What’s the error?

Sorry for the delay.


That is my code and on iphones it goes to NotGotLocation but androids gotLocation
options is just
{enableHighAccuracy: True}

You should always check for permission before calling getCurrentPosition.

There’s an object passed to the error handler as a parameter that tells you what the error is.

Read here: - handling errors

Lastly, make sure to set a timeout on the getCurrentPosition. The default timeout is very short and some devices will timeout before your code can even get a chance to work properly.