title: WKwebview Javascript function Geolocation
body: <p>Hello Guys I'll hope that you can help me. </p>
  
  <p>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!</p>
  
  <pre><code>var x = document.getElementById("location");
  
  function getLocation() {
      if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(showPosition);
      } 
  }
  
  function showPosition(position) {
      x.innerHTML = "Latitude: " + position.coords.latitude + 
      "&lt;br&gt;Longitude: " + position.coords.longitude;
  }
  </code></pre>
  
  <p>I'm able to show the <code>navigator.geolocation.getCurrentPosition</code> 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)</p>
  
  <p><img src="https://i.stack.imgur.com/hPQ7B.png" alt="ask for permission"></p>
  
  <p>My question is how can i transfer the data from the App to the Javascript without a permissionrequest. I read something about <code>WKWebViewConfiguration</code> or about  <code>evaluateJavaScript(_:completionHandler:)</code> or about <code>NSBundle and NSURLRequest</code> but what is the right way or is there a better way?
  please help me I do not know how to continue</p>