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.66k stars 426 forks source link

Location tracking is inconsistent #2198

Closed mcottingham closed 1 week ago

mcottingham commented 2 weeks ago

Your Environment


### Android headless task registration
```javascript
/* _layout.js */

BackgroundGeolocation.registerHeadlessTask(async (event) => {
    if (event.name === 'heartbeat') {
        await onLocation();
    }
});

onLocation handler


/* _layout.js */

const onLocation = async (l) => {
    let taskId = await BackgroundGeolocation.startBackgroundTask();
    try {
        let location = l;
        const { attributes: { email: userEmail } } = await Auth.currentAuthenticatedUser();
        if (!location) {
            location = await BackgroundGeolocation.getCurrentPosition({ desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_NAVIGATION, samples: 3 })
        }
        await store.dispatch(updateStatus({ email: userEmail, location: toAWSLocation(location.coords), timestamp: location.timestamp }))
    } catch (ex) {
        console.log("Failed to process location", ex);
    } finally {
        await BackgroundGeolocation.stopBackgroundTask(taskId);
    }
}

We are using expo-router. We have registered / setup the BackgroundGeolocation library inside our main _layout.js file.

Expected Behavior

Actual Behavior

No exceptions are being thrown to Sentry.

mcottingham commented 2 weeks ago

@christocracy Any thoughts?

christocracy commented 1 week ago

Try latest release 4.17.5

mcottingham commented 1 week ago

Updated, we'll see how this version works. Thank you.