Agontuk / react-native-geolocation-service

React native geolocation service for iOS and android
https://www.npmjs.com/package/react-native-geolocation-service
MIT License
1.6k stars 290 forks source link

Help Needed #361

Open kamalpandey opened 2 years ago

kamalpandey commented 2 years ago

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?

mbahgatTech commented 1 year ago

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