-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
59 lines (51 loc) · 2.09 KB
/
Copy pathApp.tsx
File metadata and controls
59 lines (51 loc) · 2.09 KB
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
import React, { useEffect } from 'react';
import { useCameraPermission, useMicrophonePermission } from 'react-native-vision-camera';
// Redux
import { Provider } from 'react-redux';
// Utilities
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { withIAPContext } from 'react-native-iap';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { MainNavigation } from './src/navigation/MainNavigation';
import { store } from './src/redux/store';
import { initializeData } from './src/redux/thunks';
import { ThemeProvider } from './src/theme/ThemeProvider';
function App(): React.JSX.Element {
const { hasPermission: hasVideoPermission, requestPermission: requestVideoPermission } = useCameraPermission();
const { hasPermission: hasMicrophonePermission, requestPermission: requestMicrophonePermission } =
useMicrophonePermission();
// Initialize redux store data
useEffect(() => {
store.dispatch(initializeData());
}, []);
// Check / request app permissions
useEffect((): void => {
const checkPermissions = async (): Promise<void> => {
if (!hasVideoPermission) {
const result = await requestVideoPermission();
if (!result) {
// TODO: Tell them to give permission in settings
}
}
if (!hasMicrophonePermission) {
const result = await requestMicrophonePermission();
if (!result) {
// TODO: Tell them to give permission in settings
}
}
};
checkPermissions();
}, [hasMicrophonePermission, hasVideoPermission, requestMicrophonePermission, requestVideoPermission]);
return (
<Provider store={store}>
<GestureHandlerRootView>
<SafeAreaProvider>
<ThemeProvider>
<MainNavigation />
</ThemeProvider>
</SafeAreaProvider>
</GestureHandlerRootView>
</Provider>
);
}
export default withIAPContext(App);