Expo Location don't working inside Expo Background Fetch

14 Views Asked by At
TaskManager.defineTask(BACKGROUND_FETCH_TASK, async () => {
  const now = Date.now();

  console.log(
    `Got background fetch call at date: ${new Date(now).toISOString()}`
  );

  let { status } = Location.requestForegroundPermissionsAsync();
  console.log(status);
  if (status !== 'granted') {
    console.log('Permission to access location was denied');
    return;
  }

  
    let { coords } = await Location.getCurrentPositionAsync({});
    console.log(coords);
  

  // Be sure to return the successful result type!
  return BackgroundFetch.BackgroundFetchResult.NewData;
});

When I use let { coords } = await Location.getCurrentPositionAsync({}); console.log(coords);

Background Fetch don't work. How can I solve this?

When I use Backgroung Fetch with a console.log('Any Text') it works properly and it shows message every 1 minute. But if I use Location.getCurrentPositionAsync({}) It don't show the result.

0

There are 0 best solutions below