I have a HeadLess JS task running and getting the current user location using the react-native-geolocation-service api. It works fine while app is in foreground, but as soon as i change it to background the api returns an error: message:Location request timed out. code:3.
I have triend many solutions, from setting enableHighAccuracy to false, deleting the other properties and nothing changes.
Is there anyone who can help me solve this problem?
export const getCurrentPosition =
async (): Promise<GeolocationPosition> => {
return new Promise((resolve, reject) => {
Geolocation.getCurrentPosition(
(position) => {
const {
coords: { latitude, longitude },
} = position;
resolve({ latitude, longitude });
},
(error) => {
// See error code charts below.
console.debug(error.code, error.message);
reject();
},
{
enableHighAccuracy: true,
timeout: 15000,
maximumAge: 10000,
},
);
});
};