问题描述
无论何时脚本使用 HTML5
的地理定位API请求地理位置, UIWebView
都会要求使用权限iOS位置服务。
这非常烦人,尤其是当您加载静态 HTML
文件时,它会一直询问每个文件的权限,即使用户已经为应用程序本身授予了此权限。
有没有办法阻止它?
我知道,在safari上,地理位置权限基于域名,我同意在请求为其他域名完成时请求权限,但不应该在加载静态HTML或本地文件时,UIWebView具有与应用程序相同的地理位置权限?
我做错了什么?
您始终可以将应用程序的地理位置传递给加载到WebUIView中的JavaScript。在WebUIView中查找'stringByEvaluatingJavaScriptFromString'?
Whenever an script requests the geolocation using HTML5
's geolocation API, the UIWebView
asks for a permission to use the iOS location services.
This is pretty annoying, specially when you load static HTML
files, it keeps asking the permission for each file, even if the user already granted this permission for the app itself.
Is there a way to prevent it?
I know that on safari the permission for geolocation is based on the domain and I agree on asking for permission when the request is done for a different domain, but shouldn't the UIWebView have the same geolocation permission as the app when loading static HTML or local files?
Am I doing something wrong?
You can always pass the geolocation from your app to the javascript loaded into the WebUIView. Look for 'stringByEvaluatingJavaScriptFromString' in WebUIView?
这篇关于在UIWebView中防止恼人的HTML5地理位置警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!