Android 如何避免;发送';地理位置变化';“没有注册听众”;在react native中发出警告?
我将获得react native中的当前位置 我使用的代码如下:Android 如何避免;发送';地理位置变化';“没有注册听众”;在react native中发出警告?,android,ios,google-maps,react-native,Android,Ios,Google Maps,React Native,我将获得react native中的当前位置 我使用的代码如下: if(Platform.OS == "android") { try { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, {
if(Platform.OS == "android") {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
'title': 'Location Permission',
'message': 'Wichz would like to access your location to get your things.'
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
// console.warn("You can use locations ")
} else {
// console.warn("Location permission denied")
}
} catch (err) {
// console.warn(err)
}
}
this.watchID = navigator.geolocation.watchPosition((position) => {
this.setState({
selectedLat: position.coords.latitude,
selectedLng: position.coords.longitude
});
Global.selectedLat = position.coords.latitude;
Global.selectedLng = position.coords.longitude;
this.getcurrent_address(position.coords.latitude, position.coords.longitude);
}, (error)=>console.log(error.message),
{enableHighAccuracy: false, timeout: 3, maximumAge: 1, distanceFilter: 1}
);
并在ios项目中添加如下位置使用说明:
它在ios和android上都运行良好,但我得到了如下警告框:
如何避免这个警告框?谢谢