Closed felipemelendez closed 4 months ago
You don’t need any of that.
preventSuspend doesn’t work after terminate. 99% of use-cases don’t need preventSuspend. You probably don’t need it.
the minimum distance to travel for tracking to engage (while in background / terminated) is 200 meters.
This is all easily experimented with in the iOS Simulator with location simulated with Freeway Drive and debug: true enabled.
This is all easily experimented with in the iOS Simulator with location simulated with Freeway Drive and debug: true enabled.
Ever since I installed this API, I have not been able to use the iOS Simulator, I get this error when I try to run it: ERROR Invariant Violation: Your JavaScript code tried to access a native module that doesn't exist.
So I've been testing on a development build.
I suggest you Google that and figure out how to fix it.
You’re wasting your time not being able to quickly experiment, answering questions in 30s that take 20 min of walking outside to test.
yep, I had been testing by taking my dog for a walk around the block, after this exchange I decided to hop in the car and it turns out that my block has a radius < 200 meters. As soon as I exited the 200 meter radius the debugger came to life.
I wish we could make that radius smaller somehow...
Adding this for posterity.
I am using Expo and my problem with the simulator was solved by creating a development build and installing the build in the simulator.
Here are the respective docs: Creating a dev build: https://docs.expo.dev/develop/development-builds/create-a-build/
Installing dev build in the simulator: https://docs.expo.dev/build-reference/simulators/#installing-build-on-the-simulator
Your Environment
react-native -v
): 0.74.2For BackgroundGeolocation
For BackgroundFetch
Expected Behavior
If the app has been terminated, I want to still be able to update the db with the user's location when the user exits a
stationaryRadius
of 25 meters.Context
I am developing an app where the predominant activity will be walking. The app will not have a button to manually switch the activity (not an exercise app), but there will be a range of dates in which I want to be able to start the background location when the user moves outside a
stationaryRadius
of 25 meters.For this, I am leveraging
react-native-background-geolocation
andreact-native-background-fetch
From the docs I see that
stopOnTerminate
enables a backup motion-detection mechanism with a geofence radius of 200 meters - that is too large for pedestrian activity.I see that with iOS, 200 meters is a minimum requirement, but then there's
preventSuspend
, which I believe can help reduce or eliminate that minimum radius if Apple approves background location capability.Questions
onLocation
is not working with that configuration, do I need to useonHearbeat
to leveragepreventSuspend
?If I do need to use
onHeartbeat
, and the system wakes up when the user exits thestationaryRadius
will it remain awake even after the user stops moving?OR, am I misunderstanding this completely and the only way for the system to wake up and perform a location update is to wait 15 minutes (i.e.
minimumFetchInterval: 15
)?