Hello guys… I’ve been trying to implement Location.watchPositionAsync and it’s working fine… but I just can’t figure out how to remove the subscription, the code is as follows:
_checkIn = async () => {
if (this.state.checked_in) {
Alert.alert("YOU ARE ALREADY CHECKED IN!");
} else {
this.setState({ checked_in: true, });
Alert.alert("SUCCESSFULLY CHECKED IN!");
Expo.Location.watchPositionAsync({
enableHighAccuracy: true,
distanceInterval: 10,
}, NewLocation => {
let coords = NewLocation.coords;
console.log("NEW LOCATION COORDS", coords);
});
}
}
_checkOut = async () => {
if (!this.state.checked_in) {
Alert.alert("YOU ARE ALREADY CHECKED OUT!");
} else {
Expo.Location.watchPositionAsync().remove();
this.setState({ checked_in: false, });
Alert.alert("SUCCESSFULLY CHECKED OUT!");
}
}
Note: I tried different variations to remove the subscription… but none seems to work. What am I doing wrong?