Ionic 2 Geolocation partialy working on Android 6.0

On my android 5.0 phone and on the 7.0 emulator, it’s working good.

But on Android 6 it’s not working when i launch the app with the gps disabled. The Diagnostic.isLocationAuthorized of cordova tells me that it’s authorised, i have after that Diagnostic.isLocationAvailable() that checks if the gps i activated. If not i redirect the user to the settings, then after he activates it, nether the Geolocation.watchPosition or the googleMap.getLocation() manage to get any coordinates.

If open the app with the gps, it’s working fine. I wonder if the fact that the app gets in background mess things up on 6.0.

Any suggestion ?

Just to make sure:
Is it supposed to work without an app restart? Do you know other apps where it works that way?

I don’t know, I assume it has to work if it does on 5.0 and 7.0.

I resolved the problem, by restarting the app when user comes back from the settings.

Diagnostic.isLocationAvailable().then(result => {
    console.log('Diagnostic-main :' + result);
    if(result && this.activatingGps){
      window.location.reload();
    }else if(!result){
      this.activatingGps = false;
    }
  });
1 Like