react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Location Tracking Persists After Stopping in react-native-background-geolocation

Open RafikMk opened this issue 1 year ago • 2 comments

I'm encountering an issue with the react-native-background-geolocation SDK where, even after calling the appropriate methods to stop tracking and remove listeners, the app continues to track the location. This is indicated by the persistent location icon in the header of my iPhone.

Steps to Reproduce:

  1. Import and initialize react-native-background-geolocation in a React Native application.
  2. Start location tracking using BackgroundGeolocation.start().
  3. Attempt to stop location tracking using the following code: import BackgroundGeolocation from 'react-native-background-geolocation';
BackgroundGeolocation.stop(() => {
    console.log("BackgroundGeolocation tracking stopped.");
    BackgroundGeolocation.removeListeners();
    BackgroundGeolocation.stopWatchPosition();
});
  1. Observe that the location icon remains visible in the iPhone's header, suggesting that location tracking is still active.

Expected Behavior: After executing stop(), removeListeners(), and stopWatchPosition(), the location tracking should completely stop, and the location icon in the iPhone's header should disappear.

Actual Behavior: Despite calling the stop and remove methods, the location icon remains active, indicating that the app is still tracking location.

Environment:

React Native version: 0.73.4 react-native-background-geolocation version: 4.16.5 Platform: iOS Device: iPhone 14 pro max Additional Information: I've verified that all listeners are removed and that all stop methods are called, yet the problem persists. It seems that the location service is not fully stopped or released.

RafikMk avatar Aug 19 '24 13:08 RafikMk

even after calling the appropriate methods to stop tracking and remove listeners, the app continues to track the location. This is indicated by the persistent location icon in the header of my iPhone.

Listeners have no effect on tracking, just as disconnecting speakers from your stereo system has no effect on the music playing or not. Event-listeners are nothing more than callback functions in an Array.

When you call .stop(), everything is stopped, 100% guaranteed, just like turning off the [POWER] button on a stereo-system stops the music from playing.

the location icon remains active, indicating that the app is still tracking location.

That is not the fault of this plugin. You have some other plugin causing that (eg: a Map component).

christocracy avatar Aug 19 '24 13:08 christocracy

You can easily verify that the plugin is not at-fault by observing the logs (with LOG_LEVEL_VERBOSE; see API docs Config.logLevel). After calling .stop(), you will see no more locations recorded by this plugin in your logs. You can fetch 3 days worth of the plugin's log database using method .emailLog.

christocracy avatar Aug 19 '24 13:08 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Sep 19 '24 02:09 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Oct 03 '24 02:10 github-actions[bot]