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

How to Activate GPS Icon in react-native?

$
0
0

I want to appear GPS Icon on the status bar when I open app or screen that's contain Map, So I add a function that asks a user at the first time to allow Location permission and it's work very well and I can get Lat/Long but GPS "Location" Icon did not activate so how can I force an app to activate this icon?

GPS

here's my Ask for permission function

 async requestLocationPermission() {    try {      const granted = await PermissionsAndroid.request(        PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,        {          title: 'App Location Permission',          message: 'App needs access to your Location ',          buttonNeutral: 'Ask Me Later',          buttonNegative: 'Cancel',          buttonPositive: 'OK',        },      );      if (granted === PermissionsAndroid.RESULTS.GRANTED) {        this.getLocation();      } else {        this.setState({next: false});      }    } catch (err) {      console.log('err ', err);    }  }getLocation = async () => {    const {companyLocation, Domain} = this.props.navigation.state.params;    Geolocation.getCurrentPosition(      position => {        this.setState(          {            mapData: {              latitude: position.coords.latitude,              longitude: position.coords.longitude,              latitudeDelta: 0.015,              longitudeDelta: 0.0121,            },            markerData: {              latitude: position.coords.latitude,              longitude: position.coords.longitude,              latitudeDelta: 0.015,              longitudeDelta: 0.0121,            },            error: null,          },          () => {            let {              latitudeDelta,              longitudeDelta,              ...userLocation            } = this.state.mapData;            let howFar = Math.round(haversine(userLocation, companyLocation));            howFar > Domain              ? (alert('we not work in your area.'),                this.setState({next: false}))              : null;          },        );      },      error => this.setState({error: error.message}),    );    this.watchID = Geolocation.watchPosition(position => {      const latitude = position.coords.latitude;      const longitude = position.coords.longitude;      this.setState({      mapData: {        latitude: latitude,        longitude: longitude,        latitudeDelta: 0.015,        longitudeDelta: 0.0121,      },    });    });  };

Viewing all articles
Browse latest Browse all 30345

Trending Articles



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