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

expo-location not working in ios and not showing location permission in app settings

$
0
0

I am trying to get current location in IOS 14, but i am getting no response and when i check in exposettings it's not showing location permission there. I have checked in both simulator and physical device.

Hook Code

import { useEffect, useState } from "react";import * as Location from "expo-location";export default useLocation = () => {  const [location, setLocation] = useState();  const getLocation = async () => {    try {      const { granted } = await Location.requestPermissionsAsync();      if (!granted) return;      const {        coords: { latitude, longitude },      } = await Location.getLastKnownPositionAsync();      setLocation({ latitude, longitude });    } catch (error) {      console.log(error);    }  };  useEffect(() => {    getLocation();  }, []);  return location;};

Response

undefined

Viewing all articles
Browse latest Browse all 16750

Trending Articles



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