我有一个应用程序,它执行简单的教科书 navigator.geoLocation.watchPosition(...) 在 iOS 5.x 中运行良好,无论是在 Safari 还是作为网络应用程序(使用 apple-mobile-web-app-capable meta标记).
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).
但是,在 iOS6 中,GeoLocation 在 web 应用程序中不起作用.它仍然可以按预期在 safari 中运行,但是当我运行 webapp 时,它会提示我提供位置许可,然后静默失败.我看到了位置图标,但 watchLocation 没有引发任何事件.我没有收到错误事件或任何位置事件.
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.
有人遇到过这种情况吗?任何解决方法?它绝对是特定于 iOS6 的,也特定于 apple-mobile-web-app-capable/webapp.
Has anyone run into this? Any workarounds? It's definitely iOS6 specific and also specific to the apple-mobile-web-app-capable/webapp.
这绝对是一个错误,但我找到了解决方法.你不会喜欢这个,但至少它会让你的网络应用程序再次运行.您需要检查 User Agent 标头,如果它包含iPhone OS 6",则不要使用:
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" />
是的,这意味着它不是真正的网络应用程序,您将获得 Safari 页眉和页脚栏.但至少它会让你的应用在主屏幕上再次运行.您可以访问我的网站 www.nextbus.com 了解其工作原理.
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.
请注意,Google 似乎遇到了这个问题.尝试访问 maps.google.com
,然后将网络应用程序添加到您的主屏幕.地理位置可以解决这个问题,但您确实会看到丑陋的 Safari 页眉和页脚栏.
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.
请向苹果大声抱怨!
这篇关于iOS 6 破坏了 webapps 中的 GeoLocation (apple-mobile-web-app-capable)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!