-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
56 lines (46 loc) · 1.39 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
import 'react-native-gesture-handler';
import Providers from './src/navigation/Providers';
import React, {useEffect} from 'react';
import {StatusBar, PermissionsAndroid, Platform} from 'react-native';
import Geolocation from '@react-native-community/geolocation';
import Router from './src/navigation/root';
navigator.geolocation = require('@react-native-community/geolocation');
const App: () => Node = () => {
const androidPermission = async () => {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
title: "Sabot App Location Permission",
message:
"Sabot App needs access to your location ",
buttonNeutral: "Ask Me Later",
buttonNegative: "Cancel",
buttonPositive: "OK"
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the location");
} else {
console.log("Location permission denied");
}
} catch (err) {
console.warn(err);
}
}
useEffect(() => {
if (Platform.OS === 'android') {
androidPermission();
} else {
// IOS
Geolocation.requestAuthorization();
}
}, [])
return (
<>
<StatusBar barStyle="dark-content" />
<Providers />
</>
);
};
export default App;