我正在尝试在本地展会上获得位置权限,但未能这样做。 我搜索了很多,但无法找到合适的解决方案。 位置权限的代码段是:
async componentDidMount(){
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
'title': 'Location Permission',
'message': 'Allow App to use location of your device.'
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("got")
this.setState({show:false});
} else {
console.log("failed")
}
} catch (err) {
console.log('error',err)
}
}

它显示以下错误:
错误[错误:尝试使用权限API,但主机Activity未实现PermissionAwareActivity。]
我正在使用
" expo":" ^ 25.0.0", "反应":" 16.2.0", "反应原生":" https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
由于
答案 0 :(得分:1)
使用Expo Permission API
const { status } = await Expo.Permissions.askAsync(Expo.Permissions.LOCATION);
if (status === 'granted') {
const location = await Expo.Location.getCurrentPositionAsync({
enableHighAccuracy: true,
});
return location;
}