Giter Club home page Giter Club logo

Comments (10)

christocracy avatar christocracy commented on July 21, 2024

Likely because of this unnecessary and unawaited .changePace(false) before calling .stop().

BackgroundGeolocation.changePace(false);
BackgroundGeolocation.stop();

from react-native-background-geolocation.

christocracy avatar christocracy commented on July 21, 2024

Calling changePace can take several seconds to complete, where the plug-in waits for at least 3 locations to arrive, choosing the highest possible accuracy.

completely unnecessary when you’re just going to call .stop right after.

from react-native-background-geolocation.

judeProground avatar judeProground commented on July 21, 2024

Thank you for your response. I removed changePace, but the problem still persists.
I will try a few more times!

from react-native-background-geolocation.

christocracy avatar christocracy commented on July 21, 2024

The problem is in your own code.

calling .getCurrentPosition launches a foreground service too.

from react-native-background-geolocation.

judeProground avatar judeProground commented on July 21, 2024

I made a simple switch that toggles start and stop, but the problem still exists.

Code
function SettingRunningPage() {
  const [switchValue, setSwitchValue] = useState(false);
  const [changedPace, setChangedPace] = useState(false);

  const onChangeValue = async (newValue: boolean) => {
    if (newValue) {
      BackgroundGeolocation.start((state) => {
        if (state.enabled) {
          BackgroundGeolocation.changePace(true, () => {
            setChangedPace(true);
          });
        }
      });
    } else {
      BackgroundGeolocation.stop(
        (s) => {
          console.log(s);
          setChangedPace(false);
        },
        (e) => {
          console.log(e);
        },
      );
    }
    setSwitchValue(newValue);
  };

  return (
    <AppLayout Header={<NormalHeader title={'BackgroundGeolocation'} />} backgroundColor={COLORS.white} safeAreaEnabled>
      <View style={{ flex: 1, backgroundColor: COLORS.white, paddingTop: 16 }}>
        <SettingRow title={'BackgroundGeolocation'}>
          <SwitchButton value={switchValue} onChangeValue={onChangeValue} />
          <Text type="Body1_400">{`changedPace: ${changedPace}`}</Text>
        </SettingRow>
      </View>
    </AppLayout>
  );
}
video_playspeedx2.mp4

from react-native-background-geolocation.

christocracy avatar christocracy commented on July 21, 2024

You do not need to .changePace when you’re calling .stop()!!

calling .stop() stops everything.

Just delete all calls to .changePace when you’re stopping the plug-in.

from react-native-background-geolocation.

judeProground avatar judeProground commented on July 21, 2024

It's not BackgroundGeolocation.changePace, It's just useState setState to show the text changedPace

from react-native-background-geolocation.

christocracy avatar christocracy commented on July 21, 2024

Create for me a simple hello-world in a freshly generated app which reproduces it. Share it with me in a public GitHub repo.

from react-native-background-geolocation.

judeProground avatar judeProground commented on July 21, 2024

If this is not enough, I would like to suggest creating a forkable Hello World app with all the settings configured. This would make it easier for other users to create reproducible examples as well.

I’ll try to create a Hello World app and let you know

from react-native-background-geolocation.

christocracy avatar christocracy commented on July 21, 2024

If this is not enough

No. I believe the problem is in your own code.

from react-native-background-geolocation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.