This repository has been archived by the owner on Apr 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
App.js
72 lines (68 loc) · 2.09 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from 'react';
import {PermissionsAndroid, Platform} from 'react-native';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import _ from 'lodash';
import HomeScreen from './screens/HomeScreen';
import MapScreen from './screens/MapScreen';
import ArScreen from './screens/ArScreen';
const RootStack = createStackNavigator(
{
Home: HomeScreen,
Map: MapScreen,
Ar: ArScreen,
},
{
initialRouteName: 'Home',
}
);
export const requestPermissions = async () => {
if(Platform.OS === 'android') {
const cameraResult = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA)
const gpsResult = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
if(cameraResult === PermissionsAndroid.RESULTS.GRANTED && gpsResult === PermissionsAndroid.RESULTS.GRANTED){
cameraResult === true;
gpsResult === true;
}
}
return true;
}
async function requestGpsPermission() {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
title: 'GPS ACCESS',
message:
'Ask permission for GPS access',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('testAnything = ********* You can use the GPS *********');
} else {
console.log('testAnything = GPS permission denied');
}
} catch (err) {
console.warn(err);
}
}
function onPress(){
watchId = navigator.geolocation.watchPosition(
(position) => console.log("testAnything = POSICION OBTENIDA ",position.coords.latitude,position.coords.longitude)),
(err) => console.log("testAnything = Errror obteniendo posicion GPS" + err);
console.log("testAnything = watchID : "+watchId);
}
const AppContainer = createAppContainer(RootStack);
export default class App extends React.Component {
constructor (props) {
super(props)
//requestGpsPermission();
//requestCameraPermission();
requestPermissions();
}
render() {
return <AppContainer />;
}
}