mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Potential fix to expo-location crash
This commit is contained in:
parent
334978d2fd
commit
98bd8dcfb8
1 changed files with 15 additions and 14 deletions
|
@ -23,22 +23,23 @@ export default function Home() {
|
|||
latitudeDelta: 0.000235,
|
||||
longitudeDelta: 0.000067,
|
||||
};
|
||||
|
||||
async function requestLocation() {
|
||||
let { status } = await Location.requestForegroundPermissionsAsync();
|
||||
if (status !== "granted") {
|
||||
setFeedback(
|
||||
"Permission to access location was denied. Please allow permission"
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (status == "granted") {
|
||||
let location = await Location.getCurrentPositionAsync({});
|
||||
if (location) {
|
||||
setLocation(location);
|
||||
getDistance(location);
|
||||
setTimeout(async () => {
|
||||
const { status } = await Location.requestForegroundPermissionsAsync();
|
||||
if (status !== "granted") {
|
||||
setFeedback(
|
||||
"Permission to access location was denied. Please allow permission"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (status == "granted") {
|
||||
let location = await Location.getCurrentPositionAsync({});
|
||||
if (location) {
|
||||
setLocation(location);
|
||||
getDistance(location);
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
useEffect(() => {
|
||||
requestLocation();
|
||||
|
|
Loading…
Reference in a new issue