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

Background geolocation not sending location when device has not been used for a while

Open MiquelAbella opened this issue 2 years ago • 6 comments

Background geolocation not sending location when device has not been used for a while

Background geolocation does not send the location after the device has not been used for a while (changing location and not interacting with the device).

Your Environment

  • Plugin version: 4.13.3
  • Platform: Android
  • OS version: 11
  • Device manufacturer / model: Realme C25Y
  • React Native version (react-native -v): 0.71.8

Plugin Config

useEffect(() => {
    // Subscribe to events.
    const onLocation = BackgroundGeolocation.onLocation(async (location) => {
      await axios.post(
        `${URL}/api/v1/post-location/${user._id}`,
        { location },
        {
          headers: {
            Authorization: user.accessToken,
          },
        }
      );
    });

     BackgroundGeolocation.ready({
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      distanceFilter: 20,
      backgroundPermissionRationale: {
        title: "Permite a Palmira acceder a la ubicación en segundo plano?",
        message:
          "Palmira necesita la ubicación para que la persona cuidadora pueda ver donde se encuentra, si no acepta deberá ir a la configuración de la aplicación en su sitema Android",
        positiveAction: "Cambiar a permitir siempre",
        negativeAction: "Cancelar",
      },
      stopTimeout: 5,

      debug: false,
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      stopOnTerminate: false,
      startOnBoot: true,

      url: `${URL}/api/v1/post-location/${user._id}`,
      batchSync: false,
      autoSync: true,
      headers: {
        "X-FOO": "bar",
      },
      params: {
        auth_token: "",
        userId: user._id,
      },
    }).then((state) => {
      setEnabled(state.enabled);
      console.log(
        "- BackgroundGeolocation is configured and ready: ",
        state.enabled
      );
    });


    return () => {
      onLocation.remove();
    };
  }, []);

  useEffect(() => {
    if (enabled) {
      BackgroundGeolocation.start();
    } else {
      BackgroundGeolocation.stop();
    }
  }, [enabled]);

Expected Behavior

Server getting location when location changes

Actual Behavior

Server not always getting location when location changes

Steps to Reproduce

Context

Debug logs

Logs
PASTE_YOUR_LOGS_HERE

MiquelAbella avatar Sep 24 '23 17:09 MiquelAbella

Plugin version: Latest

Meaningless

christocracy avatar Sep 24 '23 18:09 christocracy

has not been used for a while

Define “a while”.

See https://dontkillmyapp.com

christocracy avatar Sep 24 '23 18:09 christocracy

How do you know the plug-in is not working? Maybe you simply have a problem with your own http requests.

see wiki “Debugging” and learn to observe logs from the plug-in log database. Also see api docs “Logger”

christocracy avatar Sep 24 '23 18:09 christocracy

Thanks for the response.

plugin version: 4.13.3 A while is about one hour in my case.

I have an alert on my android that says that the service has been startedand the time since the service started working. That is why I think that geolocation is not trigering. Is the config ok?

MiquelAbella avatar Sep 24 '23 18:09 MiquelAbella

plugin version: 4.13.3

edit your post.

Go fetch your logs.

christocracy avatar Sep 24 '23 18:09 christocracy

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

github-actions[bot] avatar May 04 '24 01:05 github-actions[bot]

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

github-actions[bot] avatar May 18 '24 01:05 github-actions[bot]