I'm having a problem with an async function not returning when running on android whereas it returns normally when run on iOS.
This is the function:
_getLocationAsync = async () => {
let {status} = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
this.setState({
errorMessage: 'Permission to access location was denied',
});
}
let location = await Location.getCurrentPositionAsync({});
this.setState({location});
return location;
};
and I'm using it in another function here:
async fetchMarkers(settings ){
console.log("fetchMarkers");
// console.log(settings);
this.setState({listLoading: true});
let location = await this._getLocationAsync();
console.log("location is ", location);
....
....
}
This line is not returning in android, but it returns in ios. In android I tried logging the value of location just before returning it in _getLocationAsync and it logs a defined and correct object, I'm wondering why it's failing to return it then:
let location = await Location.getCurrentPositionAsync({});
I'm using React Native 0.53