react-native-geolocation-service
react-native-geolocation-service copied to clipboard
Help Needed
Actually It is not a bug but I want to know the best way to handle this scenario.
If the user does not have an internet connection, I need to store the geolocation data in the app and then send it to a web server as a JSON array once the device reconnects to the internet and clear the data stored locally.
watchId.current = Geolocation.watchPosition(
(position) => {
setLocation(position);
console.log(position);
},
(error) => {
setLocation(null);
console.log(error);
},
{
accuracy: {
android: 'high',
ios: 'best',
},
enableHighAccuracy: highAccuracy,
distanceFilter: 0,
interval: 5000,
fastestInterval: 2000,
forceRequestLocation: forceLocation,
forceLocationManager: useLocationManager,
showLocationDialog: locationDialog,
useSignificantChanges: significantChanges,
},
);
What approach should i use to handle this scenario?
You can use a local device storage package like react-native-async-storage. To check for internet connection use react-native-community/netinfo