Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing annoying HTML5 geolocation alerts inside UIWebView

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?

UIAlertView requesting permission for domain

like image 413
Felipe Sabino Avatar asked Jul 07 '12 01:07

Felipe Sabino


1 Answers

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

like image 150
Stan Wiechers Avatar answered Nov 19 '22 06:11

Stan Wiechers