transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.65k stars 426 forks source link

in ios while tracking the location sometime it gives inaccurate location #1900

Closed Sarveshwins closed 11 months ago

Sarveshwins commented 11 months ago

Your Environment

npx react-native info System: OS: macOS 13.0 CPU: (8) arm64 Apple M2 Memory: 93.00 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node Yarn: 1.22.21 - ~/Documents/GitHub/alt-tomrex-app/node_modules/.bin/yarn npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm Watchman: 2023.12.04.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.14.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: Not Found IDEs: Android Studio: 2023.1 AI-231.9392.1.2311.11076708 Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild Languages: Java: 15.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: ^0.64.0 => 0.64.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Expected Behavior

i need accurate location the device

Actual Behavior

but there is difference between the actual location the device and the location the app give/displays

Steps to Reproduce

start moving with app open (app in foreground)

Context

i want to get as more as accurate location the device
as im working in the building inside the red line but it also gives the location of nearest buildings as well

Screenshot 2023-12-18 at 5 50 04 PM
christocracy commented 11 months ago

This is completely normal, especially while indoors. GPS only works outdoors. While indoors, location comes from Wifi, with typical accuracy of 40-100 meters.

abublihi commented 1 month ago

@christocracy we have the same issue indoors, but worse the location is not even within the accuracy of 40-100 meters, it is about 150-200 meters,

Do you have any ideas on how to make it work better indoors using GPS?

Our setting:

const getCurrentLocation = async () => {
  return BackgroundGeolocation.ready({
    locationAuthorizationRequest: 'WhenInUse',
    locationAuthorizationAlert: {
      titleWhenNotEnabled: lang.ENABLE_LOCATION,
      titleWhenOff: lang.ENABLE_LOCATION,
      instructions: lang.ENABLE_LOCATION_DESC,
      cancelButton: lang.CANCEL,
      settingsButton: lang.GO_TO_SETTINGS,
    },
    desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
    debug: false,
    logLevel: BackgroundGeolocation.LOG_LEVEL_OFF,
    logMaxDays: 1,
    allowIdenticalLocations: true,
    enableHeadless: true,
    showsBackgroundLocationIndicator: true,
    foregroundService: true,
    disableMotionActivityUpdates: true,
  }).then(state => {
    return BackgroundGeolocation.getCurrentPosition({
      samples: 1,
      maximumAge: 3000, // 3 seconds
      timeout: 5, // 5 seconds
      persist: false,
    });
  });
christocracy commented 1 month ago

we have the same issue indoors, but worse the location is not even within the accuracy of 40-100 meters, it is about 150-200 meters,

There is no guarantee on accuracy while indoors. It completely depends upon the nature of the environment you're in. See an accuracy if 150-200 meters while indoors is not at all unusual and theres's nothing you can do to improve it.

Do you have any ideas on how to make it work better indoors using GPS?

There is no GPS indoors. GPS is nothing more than a series of digital radio stations in space, each broadcasting a timestamp at a different channel (frequency). By the time these radio waves reach earth from way out in space, their signal-strength is highly attenuated, preventing them from passing through thick walls of a building. That's why GPS only works outdoors.

Every Android/iOS device's Location API consists of three providers:

The Location API automatically chooses the best possible location at any given time. When one provider is unavailable (eg: GPS while indoors), the location is chosen from the next-best provider.

How does Wifi Location operate? Both Google and Apple maintain a massive database of the latitude/longitude of Wifi routers (even the router in your house). How do Google and Apple know the latitude/longitude of the router in your own house?? From people driving by your house while following driving directions in a Maps app (eg: Google Maps / Apple Maps). As people move through space while following driving-directions, Google/Apple know what the current lat/lng is from GPS. They can also sense Wifi SSID out there in the environment and estimate the latitude/longitude of those SSID based upon their reported signal-strength. That is why Wifi geolocation has low accuracy — it's an estimation based upon the perceived signal-strength relative to a known GPS location.

Several years ago, I moved to a different home. While testing the plugin at home in my basement office, I noticed my location being reported from my old address. It took several weeks before this was corrected. This is because both Apple and Google hadn't yet updated their access-point database with the new lat/lng of my router.

christocracy commented 1 month ago

How can you improve the location accuracy of some particular Wifi access point? Initiate driving directions in both Apple Maps / Google Maps while sticking your phone out of the closest window to that access point (in order for your phone to "see" the GPS radio signals). Do that every day for a few weeks.

abublihi commented 1 month ago

What is the difference between DESIRED_ACCURACY_HIGH and DESIRED_ACCURACY_NAVIGATION? and dose using DESIRED_ACCURACY_NAVIGATION make accuracy better in ios?