Required Reading
Plugin Version
5.1.1
Mobile operating-system(s)
Device Manufacturer(s) and Model(s)
Google Pixel 7
Device operating-systems(s)
Android 16
React Native / Expo version
0.81.5 / 54.0.33
What happened?
The response to a call to watchPosition is supposedly a Subscription instance. However when calling remove() on that I get an error. I am unable to stop watching using the current documentation procedures.
TypeError: watchSub.remove is not a function (it is undefined)
What's a bit odd is that I log the contents of my Subscription instance and it appears to to have a remove function. But no matter what I get this error when calling it.
{"_h": 0, "_i": 3, "_j": {"_h": 0, "_i": 1, "_j": {"id": -1, "remove": [Function remove]}, "_k": null}, "_k": null}
I realize that you strongly discourage using watchPosition which is fine. We use it in rare circumstances for troubleshooting when a specific device doesn't behave as expected and stops updating even though the user reports they kept moving.
Also I tried to find an online code sample site that supports Expo with dev builds (because I'm pretty sure that Expo Go doesn't work with this plugin) but I couldn't find anything that allowed me to give you a working repro example. Let me know if there's an option I missed.
Plugin Code and/or Config
// Config / ready call.
BackgroundGeolocation.ready({
geolocation: {
desiredAccuracy: BackgroundGeolocation.DesiredAccuracy.High,
distanceFilter: 3,
disableElasticity: true,
stationaryRadius: 3,
showsBackgroundLocationIndicator: true,
},
activity: {
disableStopDetection: true,
},
app: {
backgroundPermissionRationale: {
title: "Allow **** to access this device's location in the background?",
message: 'In order to record your location in the background while running tracks please enable "{backgroundPermissionOptionLabel}" location permission',
positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
negativeAction: "Cancel"
},
},
logger: {
debug: true,
logLevel: BackgroundGeolocation.LogLevel.Verbose,
});
// Repro code:
const sleep = (ms: number) => {
return new Promise(resolve => setTimeout(resolve, ms));
}
const watchSub = BackgroundGeolocation.watchPosition({
interval: 3000
}, (location) => {
console.log('TIMED LOCATION');
}, (errorCode) => {
console.log(errorCode);
});
await sleep(10000);
console.log('watchSub', watchSub);
watchSub.remove();
Relevant log output
Required Reading
Plugin Version
5.1.1
Mobile operating-system(s)
Device Manufacturer(s) and Model(s)
Google Pixel 7
Device operating-systems(s)
Android 16
React Native / Expo version
0.81.5 / 54.0.33
What happened?
The response to a call to
watchPositionis supposedly aSubscriptioninstance. However when callingremove()on that I get an error. I am unable to stop watching using the current documentation procedures.What's a bit odd is that I log the contents of my
Subscriptioninstance and it appears to to have aremovefunction. But no matter what I get this error when calling it.I realize that you strongly discourage using
watchPositionwhich is fine. We use it in rare circumstances for troubleshooting when a specific device doesn't behave as expected and stops updating even though the user reports they kept moving.Also I tried to find an online code sample site that supports Expo with dev builds (because I'm pretty sure that Expo Go doesn't work with this plugin) but I couldn't find anything that allowed me to give you a working repro example. Let me know if there's an option I missed.
Plugin Code and/or Config
Relevant log output