Adicionado o código para obter a permissão de localização

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2025-03-17 18:30:32 -03:00
parent 9e800e149a
commit b37294e5a8
3 changed files with 68 additions and 2 deletions

View File

@ -4,9 +4,34 @@ import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import MapScreen from './src/screens/MapScreen'
import ListScreen from './src/screens/ListScreen';
import * as Location from "expo-location"
import { useEffect } from 'react';
const Stack = createStackNavigator();
let foregroundSubscription = null;
export default function App() {
const foregroundUpdate = async() =>{
const {granted} = await Location.getForegroundPermissionsAsync()
if (!granted){
console.error("Permissão Não obtida para localização")
return
}
}
useEffect(()=>{
const locationPerm = async() =>{
const foregroun = await Location.requestForegroundPermissionsAsync()
}
locationPerm()
foregroundUpdate()
},[]
)
return (
<NavigationContainer>
<Stack.Navigator>

View File

@ -11,9 +11,11 @@
"@react-navigation/native": "^7.0.15",
"@react-navigation/stack": "^7.1.2",
"expo": "~52.0.38",
"expo-location": "^18.0.8",
"expo-status-bar": "~2.0.1",
"react": "18.3.1",
"react-native": "0.76.7"
"react-native": "0.76.7",
"react-native-maps": "^1.20.1"
},
"devDependencies": {
"@babel/core": "^7.20.0"
@ -3774,6 +3776,12 @@
"@babel/types": "^7.20.7"
}
},
"node_modules/@types/geojson": {
"version": "7946.0.16",
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz",
"integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==",
"license": "MIT"
},
"node_modules/@types/graceful-fs": {
"version": "4.1.9",
"resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz",
@ -5635,6 +5643,15 @@
"react": "*"
}
},
"node_modules/expo-location": {
"version": "18.0.8",
"resolved": "https://registry.npmjs.org/expo-location/-/expo-location-18.0.8.tgz",
"integrity": "sha512-4PfkFtCeKCcDFa8aX2HcNeoEvc6SxZHHs3fhEDWPuIZU9MmIWYe9iPYynF4Qj0uK+sXYe+ALc2wIXbT8zrp6BQ==",
"license": "MIT",
"peerDependencies": {
"expo": "*"
}
},
"node_modules/expo-modules-autolinking": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/expo-modules-autolinking/-/expo-modules-autolinking-2.0.8.tgz",
@ -9122,6 +9139,28 @@
"react-native": "*"
}
},
"node_modules/react-native-maps": {
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/react-native-maps/-/react-native-maps-1.20.1.tgz",
"integrity": "sha512-NZI3B5Z6kxAb8gzb2Wxzu/+P2SlFIg1waHGIpQmazDSCRkNoHNY4g96g+xS0QPSaG/9xRBbDNnd2f2/OW6t6LQ==",
"license": "MIT",
"dependencies": {
"@types/geojson": "^7946.0.13"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"react": ">= 17.0.1",
"react-native": ">= 0.64.3",
"react-native-web": ">= 0.11"
},
"peerDependenciesMeta": {
"react-native-web": {
"optional": true
}
}
},
"node_modules/react-native-safe-area-context": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-5.3.0.tgz",

View File

@ -12,9 +12,11 @@
"@react-navigation/native": "^7.0.15",
"@react-navigation/stack": "^7.1.2",
"expo": "~52.0.38",
"expo-location": "^18.0.8",
"expo-status-bar": "~2.0.1",
"react": "18.3.1",
"react-native": "0.76.7"
"react-native": "0.76.7",
"react-native-maps": "^1.20.1"
},
"devDependencies": {
"@babel/core": "^7.20.0"