i would like to add location in react-native. I have simple app in react-native. I want to add geolocation of users who use the app. Idea is to display on admin panel in Laravel, what is current location of mobile users. Mobile app would be on react-native and web in laravel. Im looking for guide how to do this.
You can use react-native-geolocation-service library for that.
To install the library with this cmd npm install react-native-geolocation-service
And implement it like this:
...
import Geolocation from 'react-native-geolocation-service';
...
componentDidMount() {
if (hasLocationPermission) {
Geolocation.getCurrentPosition(
(position) => {
//here you'll get your current location
console.log(position);
},
(error) => {
// See error code charts below.
console.log(error.code, error.message);
},
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
);
}
}
Hope this works for you.