Cordova geolocation plugin getCurrentPosition deprecated

I have an ionic app that is trying to use geolocation exactly as shown in the docs.

var posOptions = {timeout: 10000, enableHighAccuracy: true};

  .then(function (position) {
    //  do something
  }, function(err) {
    // error

But now it has stopped working and in the console gives me this warning.

getCurrentPosition() and watchPosition() are deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See for more details.

This seems like a huge change to the w3c spec I am just surprised there is not a lot of documentation regarding it. Can anyone tell me what I am missing here.

The app is running on phones so it's listening on localhost naturally. It is talking to the server over http not https but I don't see why that would affect getting geo-coordinates

I am testing the app on the browser and as a cordova app on an ios device.


When testing out your app in the chrome browser, just change the apps url (generally to localhost:3000

You will need to make sure your media policy supports it, but you will not get a security error.

I am using HTML5 geolocation directly. But cordova plugin is just angular wrapper over it, as they say in this Stack Overflow answer.

Apparently browsers can not use geolocation from http pages any more. But for ionic this is issue only for livereload. There is some workaround described using http-proxy to have livereload working on https.

Running the app on device without livereload (i.e. 'ionic run android' without '-l' at the end) works fine.

Remember to run getCurrentPosition after deviceready event. For me this one works in one of the controllers:

            document.addEventListener("deviceready", function () {
  'deviceready fired!');
            window.navigator.geolocation.getCurrentPosition(function(position) {
      'Location from Cordova:');
      "Latitude: " + position.coords.latitude + "; Longitude: " + position.coords.longitude);

Need Your Help

Why doesn't globally declared DataTable retains its value?

c# gridview datatable

I have an aspx page with a gridview. In my page load event, I load a datatable with all the data like so:

WindowsIdentity Token in Legacy ASP

c# .net security com interop

I've created a .Net library at work that is used by all of our developers. The security part of it uses Microsoft AzMan for the security backend. In order to create a security (AzMan) ClientContext I