Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 30349

React Native-Error after declining enable location popup

$
0
0

So i am trying to make a weather app and when i decline(press NO) in the popup window for enabling location, it gives me the following error: [Unhandled promise rejection: Error: Location request failed due to unsatisfied device settings.]

The important part of the code looks like this.

    let { status } = await Permissions.askAsync(Permissions.LOCATION);
    if (status !== 'granted') {
      this.setState({
        errorMessage: 'Permission to access location was denied, please activate location and reopen the app.',
      });

    }

    let location = await Location.getCurrentPositionAsync({enableHighAccuracy:true});
    let lat = location.coords.latitude;
    let lon = location.coords.longitude;

Note: I am using the last version of react native, i am on android, i used expo-location for this and it works perfectly when i enable(press YES) location.


Viewing all articles
Browse latest Browse all 30349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>