Agontuk / react-native-geolocation-service

React native geolocation service for iOS and android
https://www.npmjs.com/package/react-native-geolocation-service
MIT License
1.61k stars 291 forks source link

location does not work in airplane mode #216

Closed ariltonJaguilar closed 3 years ago

ariltonJaguilar commented 4 years ago

It works without internet, however, when activating airplade mode, the location stops working, even with the location service enabled. For example, Google Maps continues to work normally.

The error returned: code:5 , Location settings are not satisfied

This problem appears to be an old one and was first mentioned by @vikasrai1502 in https://github.com/Agontuk/react-native-geolocation-service/issues/28#issuecomment-496371641_

More than a year ago...

If someone there needs an implementation that works in airplane mode, it WILL NOT WORK FOR YOU.

It is a pity since this implementation produces better and faster results than the most used implementation today.

mattwebhub commented 3 years ago

honestly if it worked you should probably create an issue on apple's airplane mode functionality instead 😅

Agontuk commented 3 years ago

Last time I couldn't figure out a way to solve this. I'll check again & see if there's any solution to this.

Agontuk commented 3 years ago

@ariltonJaguilar , you can try the master branch to test if location request works in airplane mode.

iBotPeaches commented 3 years ago

@Agontuk - I tried master. Enabled Airplane mode and tried twice to get location (Android, Pixel 4, Android 11).

[Mon Jan 25 2021 12:13:46.194]  LOG      {"code": 3, "message": "Location request timed out."}
[Mon Jan 25 2021 12:14:59.973]  LOG      {"code": 3, "message": "Location request timed out."}

Then I disabled Airplane mode, disabled cellular and wifi. It never got a location and never timed out. (I waited 15 minutes)

Geolocation.getCurrentPosition((location) => { foo }, {
      accuracy: {
        ios: 'best',
        android: 'high'
      },
      timeout: 15000,
      maximumAge: 0,
      distanceFilter: 1
    })
);

I then enabled cellular and I got a location within seconds. So I don't think works yet if strictly in Airplane mode.

iBotPeaches commented 3 years ago

Okay, I did some digging. I removed the latest commit since iOS didn't seem to work right and now both Android/iOS are getting a location with airplane mode with these settings


export default {
  // https://github.com/Agontuk/react-native-geolocation-service/blob/master/docs/accuracy.md
  accuracy: {
    ios: 'best',
    android: 'high'
  },
  timeout: 30000, // 30 seconds
  maximumAge: 3000, // 3 seconds
  distanceFilter: 0 // 0 meters
}

On this commit - 7f05cccc1daafe1c283e413932a7bc4d185c369b, I reverted 4a9b6ce5eb2101333d0a69e9b344060419b99af2 as I could not get a location in airplane mode with that commit.

Agontuk commented 3 years ago

@iBotPeaches , I only removed the previous restrictions. Previously you would've gotten Settings not satisfied, now it actually allows you to request a location using GPS. But it's not guaranteed, it depends on whether GPS can get a location fix or not.

Agontuk commented 3 years ago

v5.2.0 has been published with airplane mode fix. Now it allows you to request location but it isn't guaranteed.