You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

geolocation doesn't work with iOS 6 web apps!

The javascript geolocation service doesn't work with iOS 6 web apps. We have a web app that works fine in iOS 5 and it works fine in iOS 6 in Safari. But in iOS 6 if you create a web app by adding clicking on the middle icon at the bottom of Safari and adding the app to your home screen it doesn't work anymore. The geolocation call simply hangs.


I created a really simple test problem. Simply go to http://stroll.nextbus.com/webkit/test.jsp in Safari to try it out. Then create a Home Screen icon for it and click on the icon and you can see that your position is never displayed. You can look at the html to understand this trivial application.


So how does one contact Apple to get them to investigate this issue?


And by the way, we have already gotten a huge number of complaints about this problem!


-- Mike

iPhone 4S, iOS 6

Posted on Sep 19, 2012 8:50 PM

Reply
71 replies

Dec 22, 2012 8:33 PM in response to Thomas Quartus

Update: The above "workaround" requires removing

<meta name="apple-mobile-web-app-capable" content="yes" /> or changing this setting to "no". Otherwise subsequent calls to navigator.geolocation.getCurrentPosition never invoke the callback.


It also requires calculating speed directly from observations.


Agree with all that this is a huge, awful, major bug. And another reminder that poor Apple just can't seem to get geolocation right these days. (In working on this, I keep linking to Apple maps and can't help but notice that somehow they have got the cul-de-sac running right through our neighbor's house...) (Sigh.)

Jan 18, 2013 5:12 PM in response to MikeAtNextBus

The good news is: I've done it... I've figured it out. The bad news is: somebody smarter than me is going to have to tell you why this works, whereas any other variation of this solution or any of the other solutions offered don't work. This was a hard-fought victory but I'm too embarrassed to say how many hours (days) it took me to figure this out. Without further ado, here's a link to the solution. http://stackoverflow.com/a/14410106/818266

Jan 18, 2013 7:56 PM in response to Tools Dept.

Well the fix did not work for me. Maybe I did not follow the instructions completely but I think I did and I did the initialization in the windows.load event so it was early (but maybe not early enough?).


One thing I noticed independantly of your code that I never really noticed before. After you call the

watchPosition
then the
clearWatch
does not seem to work. I run the
clearWatch
periodically when I leave my maps pages and on a non home screen version the navigation icon on the top of the phone disappears. On a home screen app (same app just bookmarked to the home screen) it never goes away. And yes I did validate that it was being called with an alert just before the statement and making sure the watchID was initialized too.


So there is still some pretty broken stuff in iOS 6.

Feb 6, 2013 2:57 AM in response to renevoorburg

I tested your map and it only updates for a while. In your case, I think as soon as watchPosition has reached its timeout, then it throws a timeout error and stops. My understanding so far was that one has to explicitly call clearWatch to stop watchPosition from firing events. (in my app, I do this whenever I call watchPosition again).


I've experimented a bit with my code and tried to call watchPosition again as soon as the timeout happens, but this doesn't work reliably. Subsequent calls to watchPosition in a loaded page sometimes get valid positions, sometimes not (i.e. the accuracy is way off). At that point, I can only reset by killing Safari and loading the page again, just re-loading the page doesn't help.


Quite frustrating considering that this worked reliable on iOS5 😠

Feb 6, 2013 6:26 AM in response to XCTrails

Ok, I now tried the approach with the timer controlled getCurrentPosition instead of watchPosition, same effect. Works for the first time, on subsequent calls (i.e. to refresh a changed position) it delivers results with a bad accuracy.


There is something else I observed, though: If I task switch to the builtin maps app in that situation, maps freezes for some seconds, then has a proper position. Switching back to the webapp, I can now retrieve a valid position again.


If I run an app like MotionX-GPS in the background and set it to not turn of the GPS at all when backgrounded, all is fine, I can update the position in the webapp as often as I want.


So it seems to me as if the JS calls somehow leave the GPS in a strange state or fail to "wake it up" - apparently native apps or a browser restart reinitialize it but repeated calls via the navigator.geolocation interface don't.


So as far as I'm concerned this interface is still broken unless you only call it once (or maybe a couple of times, eventually it will fail).


Message was edited by: XCTrails

Feb 6, 2013 7:10 PM in response to XCTrails

I am using a modifed version that was described by


http://stackoverflow.com/a/14410106/818266


I did not try the version I had using the older pre iOS 6 code. Note this did not work for me before iOS 6.1.


I took the device out today for a test and at first every few minutes it did bounce around the true location by about 1/8 of a mile but then it seemed to settle down. I think it did this before iOS 6.

Feb 7, 2013 1:43 AM in response to aesculus

Well then, it seems I need to build a test app from scratch, maybe there are some side effects in my actual app. But the code for that app ran just fine on iOS5 and still does on other mobile OSes ...


But this comment in the above mentioned approach makes me wonder if this isn't some sort of twisted timing issue which popped up only in iOS 6 after all ...


"make this setTimeout delay one second longer than your watchPosition() timeout"

geolocation doesn't work with iOS 6 web apps!

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.