Thursday, July 28, 2016

Can I check devices location is open or close on React Native

Leave a Comment

Can I check devices location is open or close before using geolocation? I want to show alert message like App need to run your location, please open your devices location, when devices location is close.

Can I navigate to go native location setting both IOS and Android?

Like example -

componentDidMount() {   // Check condition device location is open or close.   if( DevicesLocation === 'close' ) {      alert('App need to run your location, please open your devices location');      // other process    } else {      navigator.geolocation.getCurrentPosition(         (position) => {            var initialPosition = JSON.stringify(position);            this.setState({ initialPosition});         },         (error) => console.log(error.message)      );   } } 

1 Answers

Answers 1

I think you can use

navigator.geolocation.getCurrentPosition(    (position) => {     //do stuff with location    },    (error) => {      this.setState({locationEnabled: false}),    },    {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}  );

For opening settings from your app, I think you will have to get your hands dirty with native code :D

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment