Forum Xamarin.Forms

UWP query GPS device from javascript in webview

I have a multi part requirement that I'm trying to get implemented, and I'd be grateful for any help that the forum can give me.

We have an app which shows an html page in a webview. This page uses a local .js file in order to do things. In particular, it can call a Navigator.Geolocation object in response to a click in order to get a location, which it puts lat and long values from into text fields.

Behind the scenes, this Navigator.Geolocation javascript object seems to be using the Geolocation API, and this works fine when the device has a wifi connection. However, when it does not have a wifi connection, it cannot reach this API, and fails as one might expect.

The device in question, a windows surface, has a Trimble R1 gps unit attached to it, which outputs NMEA data on a COM port. I have worked out how to listen for this data in the C# side of our code, and have given the user an option for selecting which port they wish to listen on.

So, long story short, what I need is for the user to press a button on a form in a webviewer, and then the javascript code to call into my C# codebehind and tell it to execute an async function, and then get the response and put it to use.

Does anyone know where there's a good example of how to write that kind of javascript call such that it would work in a Xamarin UWP app?

Sign In or Register to comment.