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

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

问题描述

我有一个应用程序,它执行一个简单的教科书 navigator.geoLocation.watchPosition(...),它在 iOS 5.x 中的 Safari 和 Web 应用程序(使用 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 在 webapp 中不起作用.它仍然按预期在 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.

推荐答案

这绝对是一个错误,但我找到了解决方法.你不会喜欢这个,但至少它会让你的网络应用程序再次运行.您需要检查用户代理标头,如果它包含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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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