位置情報権限を変更

This commit is contained in:
harukin-expo-dev-env 2024-09-20 15:14:10 +00:00
parent acc568d021
commit 7851567f4a

View File

@ -41,12 +41,16 @@ export default function Menu({ getCurrentTrain }) {
const [locationStatus, setLocationStatus] = useState(null); const [locationStatus, setLocationStatus] = useState(null);
useEffect(() => { useEffect(() => {
Location.requestForegroundPermissionsAsync().then((data) => { Location.requestForegroundPermissionsAsync().then((data) => {
setLocationStatus(data.status); setLocationStatus(
Platform.OS == "ios"
? data.status == "granted"
: data.android.accuracy == "fine"
);
}); });
}, []); }, []);
const getCurrentPosition = () => { const getCurrentPosition = () => {
if (locationStatus !== "granted") return () => {}; if (!locationStatus) return () => {};
Location.getCurrentPositionAsync({}).then((location) => Location.getCurrentPositionAsync({}).then((location) =>
makeCurrentStation(location) makeCurrentStation(location)
); );