我还添加了 在minifest.Xml文件中行的Fine.Location权限,但是什么也没有发生。我的targetdkverion = 28。 请给我建议解决方案
答案 0 :(得分:0)
您应使用react-native-geolocation-service并根据平台获得权限。在android上,您需要像下面这样自行请求权限:
if (Platform.OS !=='android' )
Geolocation.requestAuthorization()
else {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
title: 'we need GPS location service',
message:
'we need location service to provide your location',
// buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
},
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
} else {
Defaults.modal.current.renderModel(modalOptions);
return false;
}
}
catch (err) {
console.warn(err);
}
}