getLatestLocation() returns null and subscribeToLocationUpdates never fires :
import RNLocation from 'react-native-location';
RNLocation.requestPermission({ ios: 'whenInUse', android: {detail: 'coarse'}, }).then((granted) => { if (granted) { RNLocation.getLatestLocation().then((loc) => { Alert.alert(JSON.stringify(loc)); // <--- this returns null }); RNLocation.subscribeToLocationUpdates((locations) => { // <-- this never fires const {latitude, longitude} = locations[0]; Alert.alert(`${JSON.stringify({latitude, longitude})}`); }); } });`
You can solve this issue by changing the detail value for android: from coarse to fine. Now it is working as expected.
android: {detail: 'fine'},
Hope this solve your issue
1.4m articles
1.4m replys
5 comments
57.0k users