iOS 6打破了webapps中的GeoLocation(apple-mobile-web-app-capable) [英] iOS 6 breaks GeoLocation in webapps (apple-mobile-web-app-capable)

查看:131
本文介绍了iOS 6打破了webapps中的GeoLocation(apple-mobile-web-app-capable)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它可以执行一个简单的教科书navigator.geoLocation.watchPosition(...),该教程在Safari 5.x中都可以很好地工作,并且可以作为一个Web应用程序(使用具有Apple-Mobile-web-app-capable元标签)。



但是,在iOS6中,GeoLocation在webapp中不起作用。它仍然可以像预期的那样在safari中运行,但是当我运行webapp时,它会提示我提供位置权限,然后以静默方式失败。我看到位置图标,但没有事件从watchLocation抛出。我没有收到错误事件或任何地点事件。



有没有人遇到过这个问题?任何解决方法?这绝对是针对iOS6的,也是针对apple-mobile-web-app-capable / webapp的。 解决方案

错误,但我找到了解决办法。你不会喜欢这个,但至少它会让你的web应用程序再次工作。您需要检查用户代理标题,如果它包含iPhone OS 6,则不要使用:

 < meta content =yesname =apple-mobile-web-app-capable/> 

是的,这意味着它不会是真正的网络应用程序,您将获得Safari标题和页脚栏。但至少它会让你的应用程序再次从主屏幕上运行。您可以通过访问我的网站 www.nextbus.com 查看这是如何工作的。



请注意,Google似乎遇到了这个问题。尝试前往 maps.google.com ,然后将网络应用程序添加到主屏幕。这个地理位置会起作用,但你确实会看到难看的Safari页眉和页脚栏。



请大声抱怨Apple!


I have an app that does a simple textbook navigator.geoLocation.watchPosition(...) that works great in iOS 5.x both in Safari and as a web app (using apple-mobile-web-app-capable meta tag).

However, in iOS6, GeoLocation does not work in the webapp. It still works in safari as expected, but when I run the webapp, it prompts me for location permission, then silently fails. I see the location icon, but no events are thrown from watchLocation. I get no error events or any location events.

Has anyone run into this? Any workarounds? It's definitely iOS6 specific and also specific to the apple-mobile-web-app-capable/webapp.

解决方案

This is definitely a bug but I found a work around. You aren't going to like this but at least it will get your web app working again. You need to examine the User Agent header and if it contains "iPhone OS 6" then do not use:

<meta content="yes" name="apple-mobile-web-app-capable" />

Yes, this means that it won't be a true web app and you will get the Safari header and footer bars. But at least it will make your app work again from the home screen. You can see how this works by going to my site www.nextbus.com.

Note that it appears that Google ran into this problem. Try going to maps.google.com and then adding the web app to your homescreen. The geolocation will work for it but you will indeed see the ugly Safari header and footer bars.

Please complain loudly to Apple!

这篇关于iOS 6打破了webapps中的GeoLocation(apple-mobile-web-app-capable)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆