我的componentDidMount函数如下所示:
async componentDidMount() {
const hasLocationPermission = await PermissionsAndroid.check( PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION )
console.log('hasLocationPermission ====> ', hasLocationPermission) //returns true
if (hasLocationPermission) {
Geolocation.getCurrentPosition(
console.log('1 ======> ')
(position) => {
console.log('2 ====================================================>')
console.log(position);
},
(error) => {
// See error code charts below.
console.log('3 ====> ')
console.log(error.code, error.message);
},
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
);
}
else
{
console.log('Does not have permission to access location')
}
}
除了hasLocationPermission为true之外,没有任何控制台日志语句可以在其中打印。我觉得Geolocation.getCurrentPosition始终为null。我是React Native的新手,我在做错什么吗?请帮我在这里。谢谢!