Comments (2)
Difficult. we can enable it via private headers, but we don't do that that will cause App Store submits to rejected.
- (BOOL)webView:(WebView *)sender frame:(WebFrame *)frame requestGeolocationPermission:(WebGeolocation *)geolocation securityOrigin:(WebSecurityOrigin *)origin;
See also:
- http://stackoverflow.com/questions/7930494/cocoa-webview-display-permission-dialog-for-js-navigator-geolocation-getcurrentl
- http://opensource.apple.com/source/WebKit/WebKit-6531.9/mac/WebView/WebUIDelegatePrivate.h
But i did some research.
["city": "Haarlem", "country": "The Netherlands", "alt": -1.8790876865387, "cource": -1.0, "subadministrative": "Haarlem", "ocean": "", "lat": 52.3593304249772, "spreed": -1.0, "name": "Baron de Coubertinstraat 25", "countrycode": "NL", "inlandwater": "", "number": "25", "street": "Baron de Coubertinstraat", "neighborhood": "", "postal": "2037 HA", "lon": 4.66551022283385, "administrative": "North Holland", "poi": ""]
JS: Added location
Some technical scripting info.
// For later use.
let locationManager = CLLocationManager()
var currentLocation: [String: Any] = ["lat": 0, "lon": 0, "name": "", "street": "", "number": "", "city": "", "neighborhood": "", "administrative": "", "subadministrative": "", "postal": "", "countrycode": "", "country": "", "inlandwater": "", "ocean": "", "poi": ""]
func websiteWantsLocation() -> Void {
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()
print("Getting location?")
print(locationManager.location)
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [AnyObject]) {
let location: CLLocation = locations[0] as! CLLocation
CLGeocoder().reverseGeocodeLocation(location) {(let myPlacemark, theError) -> Void in
if (myPlacemark != nil) {
let place: CLPlacemark = (myPlacemark?.first)!
self.currentLocation["name"] = place.name != nil ? place.name! : ""
self.currentLocation["street"] = place.thoroughfare != nil ? place.thoroughfare! : ""
self.currentLocation["number"] = place.subThoroughfare != nil ? place.subThoroughfare! : ""
self.currentLocation["city"] = place.locality != nil ? place.locality! : ""
self.currentLocation["neighborhood"] = place.subLocality != nil ? place.subLocality! : ""
self.currentLocation["administrative"] = place.administrativeArea != nil ? place.administrativeArea! : ""
self.currentLocation["subadministrative"] = place.subAdministrativeArea != nil ? place.subAdministrativeArea : ""
self.currentLocation["postal"] = place.postalCode != nil ? place.postalCode! : ""
self.currentLocation["countrycode"] = place.ISOcountryCode != nil ? place.ISOcountryCode! : ""
self.currentLocation["country"] = place.country != nil ? place.country! : ""
self.currentLocation["inlandwater"] = place.inlandWater != nil ? place.inlandWater! : ""
self.currentLocation["ocean"] = place.ocean != nil ? place.ocean! : ""
self.currentLocation["poi"] = place.areasOfInterest != nil ? place.areasOfInterest! : ""
print(self.currentLocation)
// will be called a thousand times or so.
// Ok inject new java Thing! (Cool!)
self.mainWebview.mainFrame.javaScriptContext.evaluateScript("function navigator.geolocation.getCurrentPosition(callback, error, whatever) {callback('hi')}") // Does not work
self.mainWebview.mainFrame.javaScriptContext.evaluateScript("navigator.geolocation = {getCurrentPosition:function(call, err, we){call('hi')}}") // Does even not work
self.mainWebview.mainFrame.javaScriptContext.evaluateScript("console.log('Added location');")
}
}
currentLocation["lat"] = location.coordinate.latitude
currentLocation["lon"] = location.coordinate.longitude
currentLocation["alt"] = location.altitude
currentLocation["cource"] = location.course
currentLocation["spreed"] = location.speed
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
print("Error while updating location " + error.localizedDescription)
}
The problem i got there is i can't rewrite the navigator.geolocation
class.
For the rest, if you run:
> navigator.geolocation.getCurrentPosition(function(position) {
console.log(position);
},function(position) {
console.log(position);
});
< undefined
Then WebShell will error (in console)
JS: [object PositionError]
I don't have a solution ready, sorry.
I'll keep on looking
from webshell.
Ok, i'll think i know how to fix it.
Since
navigator.geolocation.getCurrentPosition(function(position) {
console.log(position);
},function(position) {
console.log(position);
});
is not a listener i can directly return the values. (if i save them)
but, i will make a config flag for it, because by default location needs to be disabled.
-> Note to myself: Inject hook, and return dictionary data.
from webshell.
Related Issues (20)
- Move settings to Settings.swift
- Inject JavaScript and CSS via directory.
- WebShell crashes sometimes when clicking right after starting WebShell.
- Changes in settings doesn't work
- Prepare for Swift 3 Support HOT 4
- Build succeeds, but app stalls HOT 12
- compile errors HOT 8
- Swiping for back & Forward. HOT 1
- Fix flashScreen(..)
- Add comments for Functions
- Update for Swift 4
- Remove unnecessary tests
- Remove "xcuserdatad"
- Is it possible to memorize credentials? HOT 1
- rename internal javascript function
- LoadingBar and Launching text HOT 4
- [BUG] Unknown Window class (null) in Interface Builder file, creating generic Window instead
- gmail loads in basic HTML mode HOT 2
- SSH Problem with github repository HOT 2
- WebView is deprecated since OS X 10.14, replacement WKWebView is not used
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webshell.