Android + Geolocation + CORS problem


#1

Hi,
i’m trying to use geolocation on android.
Using Ionic Diagnostic makes me see that I have all the permissions regarding Locations.
But everytime on emulator or on android device, i get an empty array for positions.
I use ‘@ionic-native/geolocation’ and no result.
Then I tried to use HTML5 navigator.getCurrentPosition and nothing happens as if i never came into the code.

      navigator.geolocation.getCurrentPosition(this.success, this.error, {
        enableHighAccuracy: true,
        timeout: 0,
        maximumAge: 0
      });
  success(pos) {
//Use data show alert
  };

  error(error) {
//Use data show alert
  };

I’m trying to contribute. Is this a CORS problem ?

Ionic Info

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.18.0
    ionic (Ionic CLI) : 3.18.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.2
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v9.1.0
    npm               : 5.5.1 
    OS                : macOS High Sierra
    Xcode             : Xcode 9.1 Build version 9B55 

Environment Variables:

    ANDROID_HOME : /Users/alencastry/Library/Android/sdk

Misc:

    backend : pro


#2

pretty sure you need to use

http://ionicframework.com/docs/native/geolocation/

to access the phone internal gps


#3

It just doesn’t work on an android device.


#4

you sure!

http://ionicframework.com/docs/native/google-maps/

it has Geolocation built in


#5

I’m absolutely sure, and i’m not the only one with this probleme.
You tell me to use this one instead to access to the geolocation ?


#6

Don’t have android yet doing IOS, but, want to port so, Im just throwing out ideas,

what about Native HTTP, that may act like a browser?

http://ionicframework.com/docs/native/http/


#7

hey, have you tried.

angular google maps, its a small package that runs so you can dev in browser and works on phone

https://angular-maps.com/