Géolocalisation en arrière-plan
This commit is contained in:
@ -11,19 +11,7 @@ export default function MapScreen() {
|
||||
const [location, setLocation] = useState<Location.LocationObject | null>(null)
|
||||
const [locationAccessGranted, setLocationAccessGranted] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
async function watchPosition() {
|
||||
let { status } = await Location.requestForegroundPermissionsAsync()
|
||||
if (status !== 'granted') {
|
||||
setLocationAccessGranted(false)
|
||||
alert("Vous devez activer votre géolocalisation pour utiliser l'application.")
|
||||
return
|
||||
}
|
||||
setLocationAccessGranted(true)
|
||||
await Location.watchPositionAsync({accuracy: Location.Accuracy.BestForNavigation}, location => setLocation(location))
|
||||
}
|
||||
watchPosition()
|
||||
}, [])
|
||||
|
||||
|
||||
return (
|
||||
<ThemedView style={styles.page}>
|
||||
|
Reference in New Issue
Block a user