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

ios Getting Location react-native/Expo

$
0
0

I am building an app totally depending on the users location, the app takes latitude and longitude of the user and depends on that retrieve the data for user

The app is working well with android but with ios is not getting the location of the user

any possible solution or something might be missed ?

and this is my code .... and this is the error

[Unhandled promise rejection: Error: Cannot obtain current location: Error Domain=kCLErrorDomain Code=0 "(null)"]

import * as Location from 'expo-location';import * as Permissions from 'expo-permissions';const getLocation = dispatch => async () => {    let {status} = await Location.requestPermissionsAsync(Permissions.LOCATION);    if (status === !'granted') {        dispatch({type: 'add_error' , error : 'Permission to access location denied'});    }    navigate('Home');    let location = await Location.getCurrentPositionAsync({});    dispatch({type : 'get_location' , payload : location});       dispatch({type : 'lat_value', payload : location.coords.latitude});    dispatch({type : 'long_value', payload : location.coords.longitude});    let keys = {        latitude : location.coords.latitude,        longitude : location.coords.longitude            }    await AsyncStorage.setItem('lat', JSON.stringify(location.coords.latitude));    await AsyncStorage.setItem('lng', JSON.stringify(location.coords.longitude));    const place = await Location.reverseGeocodeAsync(keys, 'en');        place.find( p => {            stateName =             p.region +'';            area = p.city;            country = p.country;        });        dispatch({type : 'set_country', payload: place.country});              dispatch({type: 'area' , payload : area});

Viewing all articles
Browse latest Browse all 16750

Trending Articles



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