JavaScript geolocation API broken in iOS 6 Safari
2013-01-08

I have a call like this in my application:

navigator.geolocation.getCurrentPosition @goToUserLocation, @handlePositionError

After upgrading to iOS 6, it stopped working. The exact issue is that the callback only fires once after starting the application, and after that, neither the success nor the error callback is called.

getCurrentPosition accepts a hash of additional options as the third argument, so I tried setting the timeout (and other options for good measure):

navigator.geolocation.getCurrentPosition @goToUserLocation, @handlePositionError, 
    { enableHighAccuracy: false, timeout: 100, maximumAge: 30000 }

However, it didn’t make any difference.

The next option was to try using watchPosition instead:

@watchId = navigator.geolocation.watchPosition @goToUserLocation, @handlePositionError, 
    { enableHighAccuracy: false, timeout: 100, maximumAge: 30000 }

(As I only need the current position when the user asks for it, I disable the polling in the callbacks).

This option exhibited the same behaviour. After the first successful call, callbacks aren’t executed anymore.

The issue is present in iOS 6.0, 6.0.1 and 6.0.2 (the latest release at the time of writing this). Notably, Google Chrome on iOS works as expected, so this is clearly an issue in Safari.

At this point, I haven’t been able to find a workaround.