Preventing annoying HTML5 geolocation alerts inside UIWebView

北城以北 提交于 2019-12-04 09:27:00

问题


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?


回答1:


You can always pass the geolocation from your app to the javascript loaded into the WebUIView. Look for 'stringByEvaluatingJavaScriptFromString' in WebUIView?



来源:https://stackoverflow.com/questions/11371441/preventing-annoying-html5-geolocation-alerts-inside-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!