Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as Location from 'expo-location';
- let watchPositionRemove;
- removeLocationSubscription() {
- if (watchPositionRemove) {
- console.log("watchPositionRemove._W.remove() ");
- watchPositionRemove._W.remove();
- }
- }
- getLocationAsync = async () => {
- console.log("getLocationAsync() ", this._isMounted, watchPositionRemove);
- if (!this._isMounted) return;
- console.log("working");
- let { status } = await Location.requestForegroundPermissionsAsync();
- if (status !== 'granted') {
- console.log('Permission to access location was denied');
- }
- //write code for the app to handle GPS changes
- watchPositionRemove = Location.watchPositionAsync({
- accuracy: Location.Accuracy.BestForNavigation,
- timeInterval: 1000, distanceInterval: 1
- }, (location) => {
- console.log("OS sent Location ");
- const { latitude, longitude } = location.coords
- this.getStation0FromLocation(latitude, longitude)
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement