我在我的 Android 设备上启用了定位服务,但我不断收到上述错误。它在加载 Expo(第一次)时提示我的权限请求,但我仍然收到承诺拒绝。它曾经工作正常,但突然停止工作。下面是我请求权限并执行位置的代码。
注意:这在 iOS 上运行良好,并且在托管工作流程中。
useFocusEffect(
React.useCallback(()=> {
let isActive = true;
async function getLocationAsync() {
let { status } = await Location.requestForegroundPermissionsAsync()
if (status !== 'granted'){
setErrorMsg('Permission to access location was denied')
return;
}
let location = await Location.getCurrentPositionAsync({});
setLocation(location);
console.log('Location permissions granted')
}
console.log(location)
getLocationAsync()
console.log(Permissions.LOCATION)
console.log('Location status above')
return () =>{
isActive = false
}
},
[],
)
)