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

Help Needed

Open kamalpandey opened this issue 2 years ago • 1 comments

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?

kamalpandey avatar Jun 26 '22 01:06 kamalpandey

You can use a local device storage package like react-native-async-storage. To check for internet connection use react-native-community/netinfo

mbahgatTech avatar Aug 06 '22 19:08 mbahgatTech