Problem with Location.getCurrentPositionAsync

See original GitHub issue

Hi,

I’m using Expo XDE v2.20.1, with SDK version 21 and Xcode 9, on a Macbook. I run my app in the iOS simulator.

When I invoke Location.getCurrentPositionAsyncit hangs indefinitely without returning or throwing an error.

If I call the function here below, it prints the first console log (“starting”) but nothing else, and the promise is neither resolved nor rejected.

async function getLocation () {
  const permission = await Permissions.askAsync(Permissions.LOCATION);
  const { locationServicesEnabled } = await Location.getProviderStatusAsync();
  if (permission.status === 'granted' && locationServicesEnabled) {
    console.log('starting');
    let location;
    try {
      location = await Location.getCurrentPositionAsync();
    } catch (e) {
      console.log('error', e);
    }
    console.log('done');
    return location;
  } else {
    return false;
  }
}

Notice that Permissions.askAsync and Location.getProviderStatusAsync work perfectly fine.

And now the crazy part: the same exact code when run on my colleague’s computer in the iOS simulator, or directly on my iPhone works all fine.

I’ve tried to re-install Xcode and Expo, but it didn’t help. Do you have any idea what is causing this and how to fix it? Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
nahuelhdscommented, Mar 9, 2018

In my case, doing Location.getCurrentPositionAsync({ enableHighAccuracy: true }) does the trick (I’m on Genymotion)

2reactions
bsor-devcommented, Jan 10, 2019

In my case, After I upgraded from sdk v31 to v32 after that my Location.getCurrentPositionAsync not working anymore what happen is it goes to infinite waitning.

Setting enableHighAccuracy: true does the trick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Location.getCurrentPositionAsync() never returns anything
const userLocation = await Location.getCurrentPositionAsync({accuracy: Location.Accuracy.Highest, maximumAge: 10000});.
Read more >
Location.getCurrentPositionAsync not working on Android #946
askAsync is working fine. But getCurrentPositionAsync will keep running forever. Setting any timeout will eventually go into Error: Location ...
Read more >
How to use the expo-location.getCurrentPositionAsync ... - Snyk
getCurrentPositionAsync function in expo-location ... Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately....
Read more >
Location.getCurrentPositionAsync Example - Expo Snack
Try this project on your phone! Use Expo's online editor to make changes and save your own copy.
Read more >
Can anyone spot what I'm doing wrong?
'granted') { setErrorMsg('Permission to access location was denied'); return; } let location = await Location.getCurrentPositionAsync({}) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found