位置情報権限を変更
This commit is contained in:
parent
acc568d021
commit
7851567f4a
8
menu.js
8
menu.js
@ -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)
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user