react-native-background-geolocation
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
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
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".
Also see wiki "Debugging". For device-specific issues, see https://dontkillmyapp.com
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?
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
Google Pixel 6 @ 14
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.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.