假设用户使用的地图需要该位置处于活动状态,否则,该地图将被关闭。
是否可以使用Location.hasServicesEnabledAsync()监听位置状态?
答案 0 :(得分:0)
使用:
_getLocationAsync = async () => {
let { status } = await
Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
alert('The request was denied');
}else{
try{
let location = await Location.getCurrentPositionAsync({});
// do something with location
}catch(e){
alert('We could not find your position. Please make sure your
location service provider is on');
console.log('Error while trying to get location: ', e);
}
}
}