title: Show Prompt to know the location
body: <p>I am using Xamarin WebView controller to display a web site (in both iOS/Android). The web site's home page prompts to access the device location. But that prompt is not showing when I have this website on a WebView (from the App). When I open this site on the browser, from the same mobile device it shows the message box. I am just wondering if it is possible to have such prompts on Xamarin WebView?</p>
  
  <p>Here is an example prompt.</p>
  
  <p><a href="https://i.stack.imgur.com/iTEZt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iTEZt.png" alt="enter image description here"></a></p>
  
  <p>This is all I have in the Xamarin app.</p>
  
  <pre><code>&lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
               xmlns:local="clr-namespace:nCollar"
               x:Class="nCollar.MainPage"&gt;
      &lt;ContentPage.Padding&gt;
          &lt;OnPlatform x:TypeArguments="Thickness"&gt;
              &lt;OnPlatform.iOS&gt;0,20,0,0&lt;/OnPlatform.iOS&gt;
              &lt;OnPlatform.Android&gt;0,0,0,0&lt;/OnPlatform.Android&gt;
              &lt;OnPlatform.WinPhone&gt;0,0,0,0&lt;/OnPlatform.WinPhone&gt;
          &lt;/OnPlatform&gt;
      &lt;/ContentPage.Padding&gt;
  
      &lt;WebView x:Name="webView"
                   Grid.Row="0"
                   VerticalOptions="FillAndExpand" 
                   Source="https://www.ncollar.com.au/"/&gt;
  
  &lt;/ContentPage&gt;
  </code></pre>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p><strong><em>Android</em></strong></p>
  
  <p>I've tried the solution mentioned in <a href="https://turbomanage.wordpress.com/2012/04/23/how-to-enable-geolocation-in-a-webview-android/" rel="nofollow noreferrer">this</a> post, but still it doesn't show the prompt.</p>
  
  <p><em>WebViewRenderer.cs</em></p>
  
  <pre><code>using Android.Webkit;
  using Xamarin.Forms.Platform.Android;
  
  [assembly: Xamarin.Forms.ExportRenderer(typeof(TestApp.Controls.WebView), typeof(TestApp.Droid.Renderers.WebViewRenderer))]
  namespace TestApp.Droid.Renderers
  {
      public class WebViewRenderer : Xamarin.Forms.Platform.Android.WebViewRenderer
      {
          protected override void OnElementChanged(ElementChangedEventArgs&lt;Xamarin.Forms.WebView&gt; e)
          {
              base.OnElementChanged(e);
  
              if (this.Control == null)
              {
                  return;
              }
  
              var webView = this.Element as TestApp.Controls.WebView;
              if (webView == null)
              {
                  return;
              }
  
  
             // webView. ings.JavaScriptEnabled = true;
              this.Control.Settings.DomStorageEnabled = true;
              this.Control.Settings.DisplayZoomControls = true;
              this.Control.Settings.BuiltInZoomControls = true;
              this.Control.Settings.SetGeolocationEnabled(true);
              this.Control.Settings.JavaScriptCanOpenWindowsAutomatically = true;
  
              this.Control.SetWebViewClient(new GeoWebViewClient());
              this.Control.SetWebChromeClient(new GeoWebChromeClient());
          }
      }
  
      public class GeoWebChromeClient : WebChromeClient
      {
          public override void OnGeolocationPermissionsShowPrompt(string origin, GeolocationPermissions.ICallback callback)
          {
              callback.Invoke(origin, true, false);
          }
      }
  
      public class GeoWebViewClient : WebViewClient
      {
          public override bool ShouldOverrideUrlLoading(WebView view, string url)
          {
              view.LoadUrl(url);
              return true;
          }
      }
  }
  </code></pre>
  
  <p><em>Manifest</em></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;uses-sdk android:minSdkVersion="15" /&gt;
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;application android:label="TestApp.Android"&gt;&lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong><em>iOS</em></strong></p>
  
  <p>Tried <code>NSLocationWhenInUseUsageDescription</code> in the plist file, but no difference.</p>