Problem with Location.getCurrentPositionAsync
See original GitHub issueHi,
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:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In my case, doing
Location.getCurrentPositionAsync({ enableHighAccuracy: true })does the trick (I’m on Genymotion)In my case, After I upgraded from sdk v31 to v32 after that my
Location.getCurrentPositionAsyncnot working anymore what happen is it goes to infinite waitning.Setting
enableHighAccuracy: truedoes the trick.