Geolocation won't work anymore

Hi everyone,
I just have this problem coming out, everything was fine before 4 days ago…
Now it doesn’t work.

That is the error message I receive :

getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details

I read that I needed to be in https, but how can I be https on an app ?
It works on firefox, but doesn’t work on android emulator nor iphone device.

I need you help guys !

Up please, I need some leads…

That is just a warning that it will be deprecated to use it on non HTTPS websites. But as you are using app you can ignore that.
If you are not getting data from any of those two methods then problem must be something else, look if you enabled Hight accuracy in settings of your device.

$cordovaGeolocation.getCurrentPosition(posOptions).then(function(position) { // that part of my code is not executed }, function(err) { // that part is executed console.log(err); alert(err); }); }

In browser or on device?

For anyone looking at this problem in the future, the geolocation methods are deprecated in Chromium version 50 and higher.

Which means it affects:

  • ionic serve if tested on Chrome/Chromium v50+.
    Solution: use another browser or older Chromium.

  • Crosswalk v20 and higher, on device, while using LiveReload
    Solution 1: don’t use LiveReload for testing geolocation. It works without it: try ionic run android without -l flag
    Solution 2: use older Crosswalk - v19 of Crosswalk is using Chromium v49, i.e. one version before deprecation. This can be achieved by adjusting XWALK_VERSION entry in your config.xml (see also):

  <plugin name="cordova-plugin-crosswalk-webview" spec="https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview.git">
    <variable name="XWALK_VERSION" value="19"/>
    <variable name="XWALK_LITEVERSION" value="xwalk_core_library_canary:17+"/>
    <variable name="XWALK_COMMANDLINE" value="--disable-pull-to-refresh-effect"/>
    <variable name="XWALK_MODE" value="embedded"/>
    <variable name="XWALK_MULTIPLEAPK" value="true"/>
  </plugin>
3 Likes

Are these really the only solution? Is it possible for ionic serve to run in https instead? Without using hacks and tunneling, do Ionic even support serving https?

We don’t yet but this seems like a damn good reason to add HTTPS support to ionic serve. Hmm…I’ll bring it up w/ the team

1 Like

hi, any news? …

I sincerely hope you guys are moving forward with this issue. :slight_smile:

We are planning on having HTTPS support for ionic serve in CLI 3 that is being worked on right now. No timeline.

For now, I recommend avoiding the livereload or serve for development and just doing it on device, which is often where devs go anyways once they get deeper into the app dev cycle.

We are currently experiencing this issue when developing an ionic 2 app. However, we are still running CLI 2. Now my question is if this issue has been resolved with CLI 3 and if CLI 3 supports https?

Thanks very much in advance for a short reply,
Sebastian