我试图获得反应本地博览会的位置权限,但失败了。我找了很多次,但找不到合适的解决办法。位置权限的代码片段是:
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,但主机活动没有实现PermissionAwareActivity。
我在用
“博览会”:"^25.0.0",“反应”:"16.2.0",“反应-原生”:"https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
谢谢
发布于 2018-03-21 10:35:42
使用世博许可API
const { status } = await Expo.Permissions.askAsync(Expo.Permissions.LOCATION);
if (status === 'granted') {
const location = await Expo.Location.getCurrentPositionAsync({
enableHighAccuracy: true,
});
return location;
}https://stackoverflow.com/questions/49402743
复制相似问题