問(wèn)題描述
我有一個(gè)應(yīng)用程序,它執(zhí)行簡(jiǎn)單的教科書(shū) navigator.geoLocation.watchPosition(...) 在 iOS 5.x 中運(yùn)行良好,無(wú)論是在 Safari 還是作為網(wǎng)絡(luò)應(yīng)用程序(使用 apple-mobile-web-app-capable meta標(biāo)記).
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 應(yīng)用程序中不起作用.它仍然可以按預(yù)期在 safari 中運(yùn)行,但是當(dāng)我運(yùn)行 webapp 時(shí),它會(huì)提示我提供位置許可,然后靜默失敗.我看到了位置圖標(biāo),但 watchLocation 沒(méi)有引發(fā)任何事件.我沒(méi)有收到錯(cuò)誤事件或任何位置事件.
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.
有人遇到過(guò)這種情況嗎?任何解決方法?它絕對(duì)是特定于 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.
推薦答案
這絕對(duì)是一個(gè)錯(cuò)誤,但我找到了解決方法.你不會(huì)喜歡這個(gè),但至少它會(huì)讓你的網(wǎng)絡(luò)應(yīng)用程序再次運(yùn)行.您需要檢查 User Agent 標(biāo)頭,如果它包含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" />
是的,這意味著它不是真正的網(wǎng)絡(luò)應(yīng)用程序,您將獲得 Safari 頁(yè)眉和??頁(yè)腳欄.但至少它會(huì)讓你的應(yīng)用在主屏幕上再次運(yùn)行.您可以訪問(wèn)我的網(wǎng)站 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.
請(qǐng)注意,Google 似乎遇到了這個(gè)問(wèn)題.嘗試訪問(wèn) maps.google.com
,然后將網(wǎng)絡(luò)應(yīng)用程序添加到您的主屏幕.地理位置可以解決這個(gè)問(wèn)題,但您確實(shí)會(huì)看到丑陋的 Safari 頁(yè)眉和??頁(yè)腳欄.
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.
請(qǐng)向蘋(píng)果大聲抱怨!
這篇關(guān)于iOS 6 破壞了 webapps 中的 GeoLocation (apple-mobile-web-app-capable)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!