Hello Guys I'll hope that you can help me.
I have a Wkwebview which opens a website "example.com". This website includes a Javascript file with many functions (the Javascript is not located in the local store of the app, it's recommanded by a link). In this website is also a button to locate you. If I press this button the Javascript function "getLocation()" will be called, see below. This function shows you the long- and latitude!
var x = document.getElementById("location");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
I'm able to show the navigator.geolocation.getCurrentPosition
with longitude and latitude in the native app. The Problem is that the WKwebview asked me always for permission to locate me (Note the app has already access to locate me it's always the WebView who asked)
My question is how can i transfer the data from the App to the Javascript without a permissionrequest. I read something about WKWebViewConfiguration
or about evaluateJavaScript(_:completionHandler:)
or about NSBundle and NSURLRequest
but what is the right way or is there a better way?
please help me I do not know how to continue