react-native-background-geolocation
react-native-background-geolocation copied to clipboard
geofence events are not accurate
When the exit is triggered for geofence events, the latitude and longitude captured in the geofence event are very far from the actual geofences.
Below is provided one example where exit is way off from the geofence:
The status of geofence around which the geofence is created: { latitude: 22.5811211, longitude: 88.42881829999999, radius: 200, type: "EXIT", }
Your Environment
- Plugin version: 4.14.5
- Platform: iOS
- OS version: 17.1.2
- Device manufacturer / model: Apple / iPhone 12 mini
- React Native version (
react-native -v): 0.72.3 - Plugin config
url: 'https://health-dev.x-studio.io/geofence',
headers: {
authorization: `Bearer ${AsyncStorage.getItem('@token').then(
val => {
return val ?? '';
},
)}`,
},
autoSync: true,
autoSyncThreshold: 2,
batchSync: true,
maxBatchSize: 2,
locationsOrderDirection: 'DESC',
maxDaysToPersist: 14,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
enableHeadless: true,
distanceFilter: 50,
stopOnTerminate: false,
locationAuthorizationRequest: 'Always',
backgroundPermissionRationale: {
title: "Allow access to this device's location in the background?",
message:
'We use your location to assist in your continued journey to well being by monitoring breaches to inclusion/exclusion zones set up or allowed by you even when you are not using the app',
positiveAction: 'Change to allow all the time',
negativeAction: "I'm not sure about this",
},
geofenceInitialTriggerEntry: true,
scheduleUseAlarmManager: true,
heartbeatInterval: 1 * 10 * 60,
logLevel: 5,
startOnBoot: true,
preventSuspend: true,
geofenceModeHighAccuracy: true,
schedule: [
'1-7 10:00-10:30 location',
'1-7 12:00-12:30 location',
'1-7 14:00-14:30 location',
'1-7 16:00-16:30 location',
'1-7 18:00-18:30 location',
'1-7 20:00-20:30 location',
'1-7 00:00-23:59 geofence',
],
});
console.log('- BackgroundGeolocation is ready: ', state);
BackgroundGeolocation.startSchedule();
Expected Behavior
Expected to get the latitude and longitude of onGeofence event triggered to be slightly closer to the geofence
Actual Behavior
The latitude and longitude of onGeofence event triggered is very far from the geofence.
Steps to Reproduce
- The app was in killed state. (removed from background tasks)
- There was network connectivity. (From cellular network).
- was moving in a vehicle crossing the geofences
Context
Debug logs
Logs
[background-geolocation (1) 2.log](https://github.com/transistorsoft/react-native-background-geolocation/files/14209637/background-geolocation.1.2.log)
This is not unusual. Geofences are monitored by the OS. The plug-in is merely the messenger, sending an event to you with the data provided by the OS.
Geofence exit events are typically fired about 100 meters outside the geofence but can take more distance depending upon the nature of the environment and presence of wifi signals and spacing of cell towers.
There is nothing the plug-in can do to make geofences fire earlier.
I have also noticed this, and sometimes it is not just a few 100 meters.
It seems like, it takes the current location of when the sync happened instead of the location recorded at the time of Geofence trigger event.
@christocracy
it takes the current location of when the sync happened instead of the location recorded at the time of Geofence trigger event.
Events are inserted into the plugin's own SQLite database with the timestamp of the time it occurred. Records in the plugin's SQLite database are immutable (impossible to change once inserted).
The timestamp of geofence events are not the timestamp when the "sync" occurred.
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.