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

Stopped tracking after a day.CLarity on How to track location 24/7 all time in any app state till app is unistalled, which method and how exactly can i get this

Open Vijay-CareAllianz opened this issue 1 year ago • 6 comments

Your Environment

  • Plugin version: ^4.14.3
  • Platform: Android
  • OS version:
  • Device manufacturer / model:
  • React Native version (react-native -v):
  • Plugin config
PASTE_YOUR_CODE_HERE
  async function BackGroundLocation2 () {
    //works even when phone is locked 
    BackgroundGeolocation.ready({
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, 
      distanceFilter: 10,
      debug: false, // <-- enable this hear sounds for background-geolocation life-cycle.
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      stopOnTerminate: false,   // <-- Allow the background-service to continue tracking when user closes the app.
      startOnBoot: true,        // <-- Auto start tracking when device is powered-up.
    }).then(state => {
      // console.log('- BackgroundGeolocation is ready: ', state);
      BackgroundGeolocation.start();
      BackgroundGeolocation.getCurrentPosition().then((res)=>{
        console.log('res',res.coords)
        updateinDB(res.coords.latitude,res.coords.longitude)
      })
    }).catch(error => {
      console.warn('- BackgroundGeolocation error: ', error);
    });
  }
  useEffect(()=>{
    const getPermissions = async () => {
      const backgroundgranted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION,
        {
          title: 'Background Location Permission',
          message:
            'We need access to your location ' +
            'so you can get live quality updates.',
          // buttonNeutral: 'Ask Me Later',
          // buttonNegative: 'Cancel',
          // buttonPositive: 'OK',
        },
      );
      if (backgroundgranted === PermissionsAndroid.RESULTS.GRANTED) {
        //do your thing!
        ReactNativeForegroundService.add_task(
          () => {
            // BackgroundGeolocation1();
            BackGroundLocation2();
          },
          {
            delay: 300000,
            onLoop: true,
            taskId: 'taskid',
            onError: (e) => console.log('Error logging:', e),
          },
        );
      }
    }
    getPermissions();
  },[]) 

Expected Behavior

Should track every 5 mins (or given frequency) in any app state(app killed, app in background or phone locked) for unlimited time

Actual Behavior

Stopped working after 1 day ( 12 hrs to be precise)

Context

Debug logs

Logs
PASTE_YOUR_LOGS_HERE

Vijay-CareAllianz avatar Oct 30 '23 11:10 Vijay-CareAllianz

When you call .start(), the plug-in will track the device forever, until told to .stop().

The plug-in only tracks when the device is detected to be moving.

Read the wiki "Philosophy of Operstion".

christocracy avatar Oct 30 '23 12:10 christocracy

Also see wiki "Debugging". For device-specific issues, see https://dontkillmyapp.com

christocracy avatar Oct 30 '23 12:10 christocracy

The website you posted doesn't seem to exist. Are you saying it's not something we developers can control? I'm on iOS and it seems iOS is pausing the app's execution about 5 min. after it's sent to the background. Can we do something about this, or not?

DeveloperMCD avatar Oct 30 '23 18:10 DeveloperMCD

The website you posted doesn't seem to exist.

It works fine for me.

Are you saying it's not something we developers can control?

Yes.

I'm on iOS and it seems iOS is pausing the app's execution about 5 min. after it's sent to the background. Can we do something about this, or not?

I carry a number of devices around with me everywhere I go, for years. I do not have a problem with my devices tracking me.

iPhone 15 Pro @ 17.0.3

Screenshot 2023-10-30 at 2 35 44 PM

Google Pixel 6 @ 14

Screenshot 2023-10-30 at 2 36 17 PM

christocracy avatar Oct 30 '23 18:10 christocracy

Have you read the wiki "Philosophy of Operation"? This plug-in tracks the device only when the device is detected to be moving. When the device is stationary, there is no location recorded.

christocracy avatar Oct 30 '23 20:10 christocracy

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

github-actions[bot] avatar May 02 '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 16 '24 01:05 github-actions[bot]