-
Notifications
You must be signed in to change notification settings - Fork 435
Open
Labels
Description
Required Reading
- Confirmed
Plugin Version
4.18.8
Mobile operating-system(s)
- iOS
- Android
Device Manufacturer(s) and Model(s)
iPhone 12 iOS 18.1 on Simulator
Device operating-systems(s)
iOS 18.1
React Native / Expo version
expo 53.0.19
What happened?
Although coords is defined to be present in location, it is sometimes undefined. There is no clear pattern. I left the app running with "City Bicycle Ride" for a while, and sometimes it happens. In my app, I had to verify that the coords were set before using it.
// A part of a zustand useLocationStore that keep all time the latest location
locationSubscription = BackgroundGeolocation.onLocation((location) => {
if (!location.coords) {
console.warn("Received location without coordinates:", location); // {"error": 0}
return;
}
set({ currentLocation: location });
});
It's like the success callback is being executed with an error code
static onLocation(success: (location:Location)=>void, failure?:(errorCode: LocationError) => void):Subscription;
Plugin Code and/or Config
export function initGeolocation() {
return BackgroundGeolocation.ready({
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 50,
stopOnTerminate: false, // Continue tracking even if the app is terminated.
startOnBoot: true, // Restart tracking when the device restarts.
enableHeadless: true, // Support for background service when app is not active.
locationAuthorizationRequest: "Always",
foregroundService: true,
});
}